forked from ghedipunk/PHP-Websockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testwebsock.php
26 lines (20 loc) · 932 Bytes
/
testwebsock.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/local/bin/php
<?php
require_once('./websockets.php');
class echoServer extends WebSocketServer {
//protected $maxBufferSize = 1048576; //1MB... overkill for an echo server, but potentially plausible for other applications.
protected function process ($user, $message) {
$this->send($user,$message);
}
protected function connected ($user) {
// Do nothing: This is just an echo server, there's no need to track the user.
// However, if we did care about the users, we would probably have a cookie to
// parse at this step, would be looking them up in permanent storage, etc.
}
protected function closed ($user) {
// Do nothing: This is where cleanup would go, in case the user had any sort of
// open files or other objects associated with them. This runs after the socket
// has been closed, so there is no need to clean up the socket itself here.
}
}
$echo = new echoServer("0.0.0.0","9000");