This article describes whether the webSocket class of swoole does not have the connections attribute? For more information about the error, see Notice: Undefined property: swoole_websocket_server: $ connections in/www/server. php on line 34.
Reply content:
Connections as $ fd) {if ($ fd! = $ Me) {$ ws-> push ($ fd, $ msg) ;}}// listens for WebSocket connection opening events $ ws-> on ('open ', function (swoole_websocket_server $ ws, $ request) {$ ws-> push ($ request-> fd, "Welcome to Tom chat platform \ n"); broadcast ($ ws, "The user {$ request-> fd} is logged on! ", $ Request-> fd) ;}); // listens to WebSocket message events $ ws-> on ('message', function (swoole_websocket_server $ ws, $ frame) {$ msg = 'from '. $ frame-> fd. ": {$ frame-> data} \ n"; broadcast ($ ws, $ msg); // $ 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) {broadcast ($ ws, "The user {$ fd} is offline! ") ;}); $ Ws-> start ();
This is the code. isn't the connections attribute used?
Your system lacks the pcre component, and the connections iterator depends on this library.
Install pcre-dev (ubuntu) or pcre-devel (centos)
Recompile and install swoole
I also encountered this problem when installing swoole1.8.7-beta. later I installed pcre, but it still didn't work. I think the sequence is wrong. I should install pcre before installing swoole.
The preceding figure shows that the webSocket class of swoole does not have the connections attribute? Error message. For more information, see PHP Chinese website (www.php1.cn )!