當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConnectionInterface::callResult方法代碼示例

本文整理匯總了PHP中Ratchet\ConnectionInterface::callResult方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConnectionInterface::callResult方法的具體用法?PHP ConnectionInterface::callResult怎麽用?PHP ConnectionInterface::callResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ratchet\ConnectionInterface的用法示例。


在下文中一共展示了ConnectionInterface::callResult方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onCall

 /**
  * {@inheritdoc}
  */
 function onCall(ConnectionInterface $conn, $id, $fn, array $params)
 {
     switch ($fn) {
         case 'setName':
             break;
         case 'createRoom':
             $topic = $this->escape($params[0]);
             $created = false;
             if (empty($topic)) {
                 return $conn->callError($id, 'createRoom', 'Room name can not be empty');
             }
             if (array_key_exists($topic, $this->roomLookup)) {
                 $roomId = $this->roomLookup[$topic];
             } else {
                 $created = true;
                 $roomId = uniqid('room-');
                 $this->broadcast(static::CTRL_ROOMS, array($roomId, $topic, 1));
             }
             if ($created) {
                 $this->rooms[$roomId] = new \SplObjectStorage();
                 $this->roomLookup[$topic] = $roomId;
                 return $conn->callResult($id, array('id' => $roomId, 'display' => $topic));
             } else {
                 return $conn->callError($id, 'createRoom', "Room '{$topic}' exists", array('id' => $roomId, 'display' => $topic));
             }
             break;
         default:
             return $conn->callError($id, '', 'Unknown call');
             break;
     }
 }
開發者ID:ksonglover,項目名稱:socketo.me,代碼行數:34,代碼來源:ChatRoom.php

示例2: onCall

 /**
  * Dispatches an event for the called RPC
  *
  * @param \Ratchet\ConnectionInterface $conn
  * @param string $id
  * @param string|\Ratchet\Wamp\Topic $topic
  * @param array $params
  */
 public function onCall(Conn $conn, $id, $topic, array $params)
 {
     $topicName = self::getTopicName($topic);
     $eventPayload = ['connection' => $conn, 'id' => $id, 'connectionData' => $this->_connections[$conn->WAMP->sessionId]];
     $event = $this->dispatchEvent('Rachet.WampServer.Rpc', $this, array_merge($eventPayload, ['topicName' => $topicName, 'topic' => $topic, 'params' => $params, 'wampServer' => $this]));
     if ($event->isStopped()) {
         $conn->callError($id, $event->result['stop_reason']['error_uri'], $event->result['stop_reason']['desc'], $event->result['stop_reason']['details']);
         $this->outVerbose('Rachet.WampServer.Rpc.' . $topicName . ' call (' . $id . ') was blocked');
         $this->dispatchEvent('Rachet.WampServer.RpcBlocked', $this, array_merge($eventPayload, ['topicName' => $topicName, 'reason' => $event->result['stop_reason']]));
         return false;
     }
     $start = microtime(true);
     $deferred = new \React\Promise\Deferred();
     $deferred->promise()->then(function ($results) use($conn, $id, $topicName, $start, $eventPayload) {
         $end = microtime(true);
         $conn->callResult($id, $results);
         $this->outVerbose('Rachet.WampServer.Rpc.' . $topicName . ' call (' . $id . ') took <info>' . ($end - $start) . 's</info> and succeeded');
         $this->dispatchEvent('Rachet.WampServer.RpcSuccess', $this, array_merge($eventPayload, ['topicName' => $topicName, 'results' => $results]));
     }, function ($errorUri, $desc = '', $details = null) use($conn, $id, $topicName, $start, $eventPayload) {
         $end = microtime(true);
         $conn->callError($id, $errorUri, $desc, $details);
         $this->outVerbose('Rachet.WampServer.Rpc.' . $topicName . ' call (' . $id . ') took <info>' . ($end - $start) . 's</info> and failed');
         $this->dispatchEvent('Rachet.WampServer.RpcFailed', $this, array_merge($eventPayload, ['topicName' => $topicName, 'reason' => [$errorUri, $desc, $details]]));
     });
     $this->dispatchEvent('Rachet.WampServer.Rpc.' . $topicName, $this, array_merge($eventPayload, ['promise' => $deferred, 'topic' => $topic, 'params' => $params, 'wampServer' => $this]));
 }
開發者ID:schnauss,項目名稱:Ratchet,代碼行數:34,代碼來源:CakeWampAppRpcTrait.php

示例3: onCall

 public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     switch ($topic->getId()) {
         case "synchronize":
             $conn->callResult($id, $this->playerData);
             break;
         default:
             $conn->callError($id, $topic, 'You are not allowed to make calls')->close();
     }
     // In this application if clients send data it's because the user hacked around in console
 }
開發者ID:steverhoades,項目名稱:async-talk-examples,代碼行數:11,代碼來源:Server.php

示例4: onCall

 public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     $roomId = $topic->getId();
     if (!array_key_exists($roomId, $this->rooms)) {
         $this->rooms[$roomId] = new \SplObjectStorage();
     }
     return $conn->callResult($id, array('id' => $roomId, 'display' => $topic));
 }
開發者ID:rdbn,項目名稱:gnome,代碼行數:8,代碼來源:Game.php

示例5: onCall

 /**
  * @param ConnectionInterface $conn
  * @param string $id
  * @param \Ratchet\Wamp\Topic|string $topic
  * @param array $params
  */
 public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     if (isset($this->command[$topic->getId()])) {
         /** @var CommandInterface $command */
         $command = $this->command[$topic->getId()];
         $result = $command->run($this->node, $params);
         $conn->callResult($id, $result);
     }
     $conn->callError($id, $topic, ['error' => 'Invalid call']);
 }
開發者ID:Bit-Wasp,項目名稱:node-php,代碼行數:16,代碼來源:Pusher.php


注:本文中的Ratchet\ConnectionInterface::callResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。