-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTCPread.php
More file actions
24 lines (22 loc) · 839 Bytes
/
TCPread.php
File metadata and controls
24 lines (22 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
define('__LIB__', dirname(dirname(__FILE__)));
require_once(__LIB__ . '/TCP/library/TCPConnection.php');
require_once(__LIB__ . '/TCP/library/TCPCallback.php');
$socket = new TCPConnection();
if (!socket_last_error($socket->getSocket())) {
if ($buffer = socket_read($socket->getSocket(), 512, PHP_NORMAL_READ)) {
$json = json_decode($buffer, true);
if ($json === null) {
//$this->getCallback()->onMessage($buffer);
echo 'ai';
} else if ($json !== null) {
/*if (array_key_exists("name", $json) === true && array_key_exists("args", $json) === true) {
$this->getCallback()->onJSONEvent($json['name'], $json['args']);
} else {
$this->getCallback()->onJSON($json);
}*/
echo 'haloo';
}
}
}
?>