Phpwebsocket based on swoole extension
Log ("onOffline :". $ client_id); // $ this-> broadcast ($ client_id, "onOffline :". $ client_id); parent: onClose ($ serv, $ client_id, $ from_id);}/*** @ see WSProtocol: onMessage () when receiving a message () */function onMessage ($ client_id, $ ws) {$ this-> log ("onMessage :". $ client_id. '= '. $ ws ['message']); $ this-> send ($ client_id, "Server :". $ ws ['message']); // $ this-> broadcast ($ client_id, $ ws ['message']);} function broadc Ast ($ client_id, $ msg) {foreach ($ this-> connections as $ clid => $ info) {if ($ client_id! = $ Clid) {$ this-> send ($ clid, $ msg) ;}}$ faster VR = new WebSocket (); $ export VR-> loadSetting (_ DIR __. "/swoole. ini "); // load the configuration file $ export VR-> setLogger (new \ Swoole \ Log \ EchoLog (true )); // Logger $ server = new \ Swoole \ Network \ Server ('0. 0.0.0 ', 9503); $ server-> setProtocol ($ virtualization VR); // $ server-> daemonize (); // as the daemon $ server-> run (array ('worker _ num' => 4 ));