Phpwebsocket-PHP source code based on swoole extension

Source: Internet
Author: User
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 ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.