当前位置: 首页>>代码示例>>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;未经允许,请勿转载。