FIN
FIN = 128
Simple WebSocket server.
$clients : array<mixed,\PHP\WebSocket\SocketClient>
Array of connected clients.
$listeners : array<mixed,\PHP\WebSocket\SocketListener>
Array of socket listeners.
(应用逻辑实现在这里)
addListener(\PHP\WebSocket\SocketListener $listener) : \PHP\WebSocket\SocketServer
Adds a new socket listener.
\PHP\WebSocket\SocketListener | $listener | Listener to add |
removeListener(\PHP\WebSocket\SocketListener $listener) : boolean
Removes an existing socket listener.
\PHP\WebSocket\SocketListener | $listener | Listener to remove |
Was the listener removed, false if not found
getListeners() : array<mixed,\PHP\WebSocket\SocketListener>
Returns all added socket listeners.
getClients() : array<mixed,\PHP\WebSocket\SocketClient>
Returns array of connected clients
Array of connected clients
getLastError(resource $socket = null) : \stdClass
Returns last socket error as an object.
The object is a basic stdClass with parameters:
resource | $socket | Optional socket resource |
Error as stdClass instance with fields code and message
getClientBySocket(resource $socket) : \PHP\WebSocket\SocketClient
Returns client by socket reference.
resource | $socket | Socket resource |
The client on the socket or null if not found