Пример #1
0
 public function __construct(Session $client)
 {
     $that = $this;
     $client->on('request', function (array $request) use($that) {
         $that->emit('data', array(json_encode($request) . "\n"));
     });
 }
Пример #2
0
 public function __construct(Session $client)
 {
     $this->client = $client;
     $that = $this;
     $client->on('end', function () use($that) {
         $that->end();
     });
 }
Пример #3
0
 public function create()
 {
     // FIXME: Random ID generation, should be unique
     $id = microtime();
     $session = new Session($id, $this->wrapper);
     $that = $this;
     $session->on('end', function () use($that, $id) {
         return $that->destroy($id);
     });
     $this->sessions[$id] = $session;
     return $session;
 }
Пример #4
0
 public function __construct(DNode $dnode, Session $client, $onReady)
 {
     $this->dnode = $dnode;
     foreach ($this->dnode->stack as $middleware) {
         call_user_func($middleware, array($client->instance, $client->remote, $client));
     }
     if ($onReady) {
         $client->on('ready', function () use($client, $onReady) {
             call_user_func($onReady, $client->remote, $client);
         });
     }
     $input = new InputStream($client);
     $output = new OutputStream($client);
     parent::__construct($output, $input);
 }