Exemplo n.º 1
0
 protected function initEvent($group)
 {
     $dispatcher = Event\EventDispatcher::getDispatcher();
     $dispatcher->addListener("socket.receive", function (Event\MessageEvent $messageEvent) {
         $message = $messageEvent->getMessage();
         $frame = $this->websocket->onMessage($message);
         if (!$frame instanceof WebSocket\Frame) {
             return;
         }
         Handshake::processProtocol($frame->getData(), $this->getConnection());
     }, $group);
     $dispatcher->addListener("server.emit", function (Event\MessageEvent $messageEvent) {
         $endpoint = $this->getRequest()->getSession()->get('endpoint', $messageEvent->getEndpoint());
         $message = $messageEvent->getMessage();
         $this->sendData(ProtocolBuilder::Event(array('name' => $message['event'], 'args' => array($message['message'])), $endpoint));
     }, $group);
 }
Exemplo n.º 2
0
 protected function processPOSTMethod()
 {
     Handshake::processProtocol($this->parseClientEmitData(), $this->getConnection());
     $response = $this->setResponseHeaders(new Response('1'));
     $this->getConnection()->write($response);
 }