Skip to content

Commit

Permalink
* Added ability to remove uri handlers
Browse files Browse the repository at this point in the history
* Fixed an issue in the socket reading functionality
  • Loading branch information
Devristo committed Feb 25, 2012
1 parent c02e307 commit bb85e2f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpws/websocket.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function readWholeBuffer($resource){
}

$result = fread($resource, $buffsize);
if($result === false || feof($resource))
if($result === false)
{
return false;
}
Expand Down
22 changes: 22 additions & 0 deletions phpws/websocket.server.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ public function setStreamContext($context){
$this->_context = $context;
}

/**
* Unassociate a request uri to a IWebSocketResourceHandler.
*
* @param string $script For example 'handler1' to capture request with URI '/handler1/'
* @param $disconnectUsers if true, disconnect users assosiated to handler.
*/
public function removeUriHandler($script, $disconnectUsers = true){

if ( empty($this->uriHandlers[$script]) ) return false;
$handler = $this->uriHandlers[$script];
unset( $this->uriHandlers[$script] );

if ($disconnectUsers) foreach($handler->getConnections() as $user){

$handler->removeConnection($user);
$user->disconnect();
}

return $handler;
}


/**
* Start the server
*/
Expand Down

0 comments on commit bb85e2f

Please sign in to comment.