-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
33 lines (24 loc) · 824 Bytes
/
test.php
File metadata and controls
33 lines (24 loc) · 824 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
25
26
27
28
29
30
31
32
33
<?php
// we need the autloader again
require 'vendor/autoload.php';
// initialize the event loop and the socket server
$loop = \React\EventLoop\Factory::create();
$socket = new \React\Socket\Server($loop);
// wait for connections
$socket->on('connection', function ($conn) {
// write the appserver.io logo to the console
$conn->write('Welcome!$');
// wait for user input => usually a command
$conn->on('data', function ($data) use ($conn) {
/*
// extract command name and parameters
list ($methodName, ) = explode(' ', $data);
$params = explode(' ', trim(substr($data, strlen($methodName))));
*/
$conn->write($data . "$");
});
});
// list the the management socket
$socket->listen(1337);
// start the event loop and the socket server
$loop->run();