Skip to content

moodrain/websocket-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebSocket-PHP

$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();

About

implement websocket protocol with php

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published