How to create an infinite loop for Clients? #78
Replies: 4 comments 1 reply
-
Hi, I suppose, that the receiveFragment function only closes the socket connection iff there are close opcode frame sent from server, e.g.:
when the messages is proceeding to send from server, then the client is still reading them, so the main point not only the client can initiate close connection, but either a server. PS Please, if u claim something to discuss technically attach some examples, it will be faster and more efficiently. |
Beta Was this translation helpful? Give feedback.
-
Thanks for answering. I have very litle knowledge about websockets. This is what I do:
It works perfectly, but I only receive one message, and I do the same on:
and if you try it you will see is sending messages every few seconds. What should I do to receive messages continuosly, not only one? |
Beta Was this translation helpful? Give feedback.
-
if I try to put it in a loop like this:
It will get me the first response, but it throws an error afterwards:
Not sure what I am doing wrong. |
Beta Was this translation helpful? Give feedback.
-
I solved it. It is ugly and surely it can be improven. I modified the read method in WcsMain.php line 404
I added a timer The counterpart is that it consumes 100% of CPU resources. I am on a AMD Ryzen 9 5950X 16-Core Processor and CPU goes to 100% Hope this can be improven. |
Beta Was this translation helpful? Give feedback.
-
Hi,
please tell me how to keep the websocket client open and listening forever?
I ask this because I can only find
$client->receive()
which closes the socket.I need something to keep getting data from the socket.
Thank you.
BTW: this is the first script that actually makes it easy to use websockets.
Beta Was this translation helpful? Give feedback.
All reactions