$server = new Server();
$server->on('open', function(Connection $client) use ($server) {
echo 'client connect, id: ' . $client->id() . ' total count: ' . count($server->clients()), PHP_EOL;
});
$server->on('close', function(Connection $client) use ($server) {
echo 'client close , id: ' . $client->id() . ' total count: ' . count($server->clients()), PHP_EOL;
});
$server->on('message', function(Connection $client, Message $message) use ($server) {
$server->sendMessage($client, \Muyu\WebSocket\Packet::MSG_TYPE_TXT, 'get ' . $message->content());
});
$server->on('send', function(Connection $client, Message $message) use ($server) {
echo 'client id ' . $client->id() . ' send ' . $message->content(), PHP_EOL;
});
$server->start();
-
Notifications
You must be signed in to change notification settings - Fork 0
moodrain/websocket-php
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
implement websocket protocol with php
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published