Workerman broadcast
- Dominant language
- PHP
- Stars
- 11.6k
- Forks
- 2.2k
- Avg merge
- 11h 30m
- Merged PRs (30d)
- 3
Description
My old code was like this
```
array(
'local_cert'=>'/var/www/mysite.com/SSL/cert.pem',
'local_pk'=>'/var/www/mysite.com/SSL/privkey.pem',
'verify_peer'=>false,
)
);
$this->worker = new \Workerman\Worker('websocket://mysite.com:888',$context);
$this->worker->transport='ssl';
$this->worker->count=40;
$this->worker->onConnect = function($connection){
$connection->onWebSocketConnect = function ($connection,$header){
$this->connections[$_GET['userId']] = $connection;
dump(array_keys($this->connections));
};
};
$this->worker->onMessage = function ($connection,$data) {
dump(count($this->connections));
foreach ($this->connections as $key => $connection) {
dump('send message to user: ' . $key);
$connection->send($data);
}
};
\Workerman\Worker::runAll();
}
}
```
In this version I can't get userID and send data to all users :(.
Please help
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the onWebSocketConnect and onMessage callbacks in the shown SocketService, then read how Worker::runAll handles workers and connections. Verify how the user ID is obtained and whether the stored connections are shared across workers; done means every connected user receives the message with the intended ID available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100