There have been only two clients with four... {Code ...}
There are only two
Four clients are opened...
Push ($ fd, $ msg) ;}}// listen to the WebSocket connection opening event $ ws-> on ('open', function (swoole_websocket_server $ ws, $ request) use (& $ fds) {$ fds [$ request-> fd] = $ request-> fd; $ ws-> push ($ request-> fd, "Welcome to Meng chat platform \ n"); broadcast ($ ws, "user {$ request-> fd} is logged on! ", $ Fds, $ request-> fd); var_dump ($ fds) ;}); // listens to WebSocket message events $ ws-> on ('message ', function (swoole_websocket_server $ ws, $ frame) use (& $ fds) {$ msg = 'from '. $ frame-> fd. ": {$ frame-> data} \ n"; broadcast ($ ws, $ msg, $ fds, $ frame-> fd ); // $ ws-> push ($ frame-> fd, "server: {$ frame-> data }"); // $ ws-> push ($ frame-> fd, "server: {$ frame-> data }");}); // listen to the WebSocket connection close event $ ws-> on ('close', function (swoole_websocket_server $ Ws, $ fd) use (& $ fds) {unset ($ fds [$ fd]); broadcast ($ ws, "user {$ fd} is offline! ", $ Fds) ;}); $ ws-> start ();
Reply content:
There are only two
Four clients are opened...
Push ($ fd, $ msg) ;}}// listen to the WebSocket connection opening event $ ws-> on ('open', function (swoole_websocket_server $ ws, $ request) use (& $ fds) {$ fds [$ request-> fd] = $ request-> fd; $ ws-> push ($ request-> fd, "Welcome to Meng chat platform \ n"); broadcast ($ ws, "user {$ request-> fd} is logged on! ", $ Fds, $ request-> fd); var_dump ($ fds) ;}); // listens to WebSocket message events $ ws-> on ('message ', function (swoole_websocket_server $ ws, $ frame) use (& $ fds) {$ msg = 'from '. $ frame-> fd. ": {$ frame-> data} \ n"; broadcast ($ ws, $ msg, $ fds, $ frame-> fd ); // $ ws-> push ($ frame-> fd, "server: {$ frame-> data }"); // $ ws-> push ($ frame-> fd, "server: {$ frame-> data }");}); // listen to the WebSocket connection close event $ ws-> on ('close', function (swoole_websocket_server $ Ws, $ fd) use (& $ fds) {unset ($ fds [$ fd]); broadcast ($ ws, "user {$ fd} is offline! ", $ Fds) ;}); $ ws-> start ();