Does the webSocket class of swoole have the connections attribute? Error

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

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.