Permalink
Browse files

Use real names for connections

  • Loading branch information...
1 parent 8b0a729 commit ae17db33597245cd1ee52bf420fe9f3b8f39e5ba @igorw igorw committed Jan 4, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 server.php
View
@@ -21,10 +21,13 @@
$socket = new React\Socket\Server($loop);
$i = 0;
+$names = ['Alice', 'Bob', 'Carol', 'Dave', 'Erin', 'Frank', 'Eve',
+ 'Mallory', 'Oscar', 'Peggy', 'Trent', 'Walter'];
-$socket->on('connection', function ($conn) use (&$i, $app) {
- $conn->id = ++$i;
+$socket->on('connection', function ($conn) use (&$i, $names, $app) {
+ $conn->id = isset($names[$i]) ? $names[$i] : $i;
$app->connect($conn);
+ $i++;
});
$socket->listen(4000);

0 comments on commit ae17db3

Please sign in to comment.