-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transferring data between workers #1028
Comments
I think this is what you want. |
I tried to remodel in a functional style. For the test. But still, global variables are unique for each worker.
I've simplified the code for the test. Clients join and a connection is created. But for example variable $users each worker has his own |
That is - I specify a variable as an array to store connections outside the function. Inside the function I call this variable with word Global and save the user and connection there. This variable is in this array. If the new connection is in the same worker, then there will be 2 connections in the array. But if the new (third) connection is in the new worker, then the new connection will be added to the empty array. That is, there will be one connection. And if, for example, there is a fourth connection, and it will be in the first worker. Then it will be added to the array where there are already 2 variables. That is, each worker has its own global variable. That is, it turns out to be 2 global variables. One stores an array with 3 connections and the second stores an array with 1 connection. And each global variable is called from the worker to which it belongs. Initially, I did it in the form of classes and specified these variables as static. And used them as static ServerChatController::$connectionsUsers, example in onMessage method
Everything works, but each worker has its own static variable Please help me make global or static variables common to all workers |
Unable to share connection objects between processes, you can notify the corresponding worker process through the channel and have the process operate the connection object on its behalf. |
Thank you very much! I used channels - now everything works correctly |
Good day!
I have the config:
How can transfer data between workers? For example, one client received a connection in the first worker. And another client received a connection in the second worker. Need to transfer data from one client to another. But this requires access to the connection from the first client in the second worker. How to correctly receive data (example Connection) from another worker?
It seems that each worker has its own global variables
The text was updated successfully, but these errors were encountered: