1: | <?php |
2: | class SocketServer |
3: | { |
4: | const WS_MAX_CLIENTS = 100; |
5: | const WS_MAX_CLIENTS_PER_IP = 15; |
6: | const WS_TIMEOUT_RECV = 10; |
7: | const WS_TIMEOUT_PONG = 5; |
8: | const WS_MAX_FRAME_PAYLOAD_RECV = 100000; |
9: | const WS_MAX_MESSAGE_PAYLOAD_RECV = 500000; |
10: | const WS_FIN = 128; |
11: | const WS_MASK = 128; |
12: | const WS_OPCODE_CONTINUATION = 0; |
13: | const WS_OPCODE_TEXT = 1; |
14: | const WS_OPCODE_BINARY = 2; |
15: | const WS_OPCODE_CLOSE = 8; |
16: | const WS_OPCODE_PING = 9; |
17: | const WS_OPCODE_PONG = 10; |
18: | const WS_PAYLOAD_LENGTH_16 = 126; |
19: | const WS_PAYLOAD_LENGTH_63 = 127; |
20: | const WS_READY_STATE_CONNECTING = 0; |
21: | const WS_READY_STATE_OPEN = 1; |
22: | const WS_READY_STATE_CLOSING = 2; |
23: | const WS_READY_STATE_CLOSED = 3; |
24: | const WS_STATUS_NORMAL_CLOSE = 1000; |
25: | const WS_STATUS_GONE_AWAY = 1001; |
26: | const WS_STATUS_PROTOCOL_ERROR = 1002; |
27: | const WS_STATUS_UNSUPPORTED_MESSAGE_TYPE = 1003; |
28: | const WS_STATUS_MESSAGE_TOO_BIG = 1004; |
29: | const WS_STATUS_TIMEOUT = 3000; |
30: | public $wsClients = array(); |
31: | public $wsClientsExt = array(); |
32: | public $wsRead = array(); |
33: | public $wsClientCount = 0; |
34: | public $wsClientIPCount = array(); |
35: | public $wsOnEvents = array(); |
36: | function wsStartServer($host, $port) {} |
37: | function wsStopServer() {} |
38: | function wsCheckIdleClients() {} |
39: | function wsAddClient($socket, $clientIP) {} |
40: | function wsRemoveClient($clientID) {} |
41: | function wsGetNextClientID() {} |
42: | function wsGetClientSocket($clientID) {} |
43: | function wsProcessClient($clientID, &$buffer, $bufferLength) {} |
44: | function wsBuildClientFrame($clientID, &$buffer, $bufferLength) {} |
45: | function wsCheckSizeClientFrame($clientID) {} |
46: | function wsProcessClientFrame($clientID) {} |
47: | function wsProcessClientMessage($clientID, $opcode, &$data, $dataLength) {} |
48: | function wsProcessClientHandshake($clientID, &$buffer) {} |
49: | function wsSendClientMessage($clientID, $opcode, $message) {} |
50: | function wsSendClientClose($clientID, $status=false) {} |
51: | function wsClose($clientID) {} |
52: | function wsSend($clientID, $message, $binary=false) {} |
53: | function log( $message ) |
54: | {} |
55: | function bind( $type, $func ) |
56: | {} |
57: | function unbind( $type='' ) |
58: | {} |
59: | } |
60: | ?> |