コード例 #1
0
ファイル: PlayzoneServer.php プロジェクト: StasPiv/playzone
 /**
  * When a new connection is opened it will be passed to this method
  * @param  ConnectionInterface $conn The socket/connection that just connected to your application
  * @throws \Exception
  */
 public function onOpen(ConnectionInterface $conn)
 {
     $wsUser = new WebsocketUser();
     $wsUser->setConnection($conn);
     $this->users->attach($wsUser);
     $this->send(new AskIntroduction(), $wsUser);
 }
コード例 #2
0
 /**
  * @param PlayzoneMessage $playzoneMessage
  * @param WebsocketUser $wsUser
  */
 private function prepareCallAccept(PlayzoneMessage $playzoneMessage, WebsocketUser $wsUser)
 {
     $data = $this->getClientMessageObject($playzoneMessage, 'Call\\ClientMessageCallAccept');
     if (!$data instanceof ClientMessageCallAccept) {
         throw new ClientMessageHandlerException("Unknown type of sent data");
     }
     $serverCallAccept = new ServerMessageCallAccept();
     $game = $this->container->get("core.handler.game")->getUserGameById((int) $data->getGameId(), $wsUser->getPlayzoneUser());
     $serverCallAccept->setGame($game);
     $serverCallAccept->setGameId($data->getGameId());
     $serverCallAccept->setCallId($data->getCallId());
     $playzoneMessage->setData(json_decode($this->container->get("jms_serializer")->serialize($serverCallAccept, 'json'), true));
 }