-
-
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
Workerman broadcast #901
Comments
The v4 (and up) don't use superglobals ($_GET, $_POST, ...). Before: $this->worker->onConnect = function($connection){
$connection->onWebSocketConnect = function ($connection,$header){
$this->connections[$_GET['userId']] = $connection;
dump(array_keys($this->connections));
};
}; Now: $this->worker->onConnect = function($connection, $request) {
$connection->onWebSocketConnect = function ($connection, $header){
$this->connections[$request->get(['userId')] = $connection;
dump(array_keys($this->connections));
};
}; Request methods: $request->get();
$request->post();
$request->header();
$request->cookie();
$request->session();
$request->uri();
$request->path();
$request->method(); |
@joanhey Does v5 support superglobals? |
Workerman v4 and v5 don't use superglobals. But you can use Adapterman: |
Hello @joanhey, but |
@joanhey Tell me please, how to do foreach. Send recived data for each client |
Workerman V5
|
@walkor Hi!
|
A single process of Workerman is capable of handling over 10,000 connections, which is sufficient for the majority of business needs. Here is an example for multiple processes broadcast. And this is an example for multiple server and processes broadcast. |
My old code was like this
In this version I can't get userID and send data to all users :(.
Please help
The text was updated successfully, but these errors were encountered: