diff --git a/README.md b/README.md index 0b175c6..6a67233 100644 --- a/README.md +++ b/README.md @@ -766,6 +766,7 @@ function chat_message(&$params, &$result) { | `$socket->broadcastAll($data)` | Send to ALL connected clients | | `$socket->join($room, $data)` | Join a room, forwarding `$data` to the room's join handler | | `$socket->leave($room, $data)` | Leave a room, forwarding `$data` to the room's leave handler | +| `$socket->disconnect()` | Close this connection | | `$socket->anyMethod($data)` | **RPC** — calls a method on the client, blocks until response (5s timeout) | **Room handlers** get `$room` — a `Q_Room` instance: @@ -2170,7 +2171,17 @@ Changes are logged to stderr: 14:32:09 hot-reload: restarting server... ``` -Polls every 2 seconds. Use in development, not production. +Polls every 2 seconds. Recommended for development. + +Even without `--hotreload`, handler changes take effect naturally: HTTP +requests fork fresh and load handlers on demand, so the next request gets the +new file. WebSocket connections and rooms keep the old code for their lifetime +— new connections pick up the change. A natural rolling deploy with no +interruption. The `--hotreload` flag adds automatic restart for class and +config changes, which are preloaded in the parent process. + +If `Q.handlers.preload` is `true` (production mode), handlers are also loaded +in the parent — use `--reload` to pick up handler changes in that case. ### Scheduler diff --git a/bin/qbixserver.phar b/bin/qbixserver.phar index 3f7e2f6..4d67984 100755 Binary files a/bin/qbixserver.phar and b/bin/qbixserver.phar differ diff --git a/src/Q.php b/src/Q.php index 244e8f4..dee6c7f 100644 --- a/src/Q.php +++ b/src/Q.php @@ -595,6 +595,9 @@ class Q_Socket /** Leave a room, optionally forwarding data to the room's leave handler */ function leave($room, $data = array()) { self::_cmd(array('cmd' => 'leave', 'socketId' => $this->id, 'room' => $room, 'data' => $data)); } + /** Disconnect this client */ + function disconnect() { self::_cmd(array('cmd' => 'disconnect', 'socketId' => $this->id)); } + /** * Call a method on the remote client. Blocks until the client responds. * The client must have registered a handler via qs.handle('methodName', fn). diff --git a/src/Q/WebSocket.php b/src/Q/WebSocket.php index 9100e93..c786447 100644 --- a/src/Q/WebSocket.php +++ b/src/Q/WebSocket.php @@ -874,6 +874,9 @@ class Q_WebSocket case 'ack': self::sendAck($cmd['socketId'], $cmd['ackId'], $cmd['data']); break; + case 'disconnect': + self::disconnect($cmd['socketId']); + break; case 'rpc': self::handleRpc($cmd); break;