当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectionInterface::callError方法代码示例

本文整理汇总了PHP中Ratchet\ConnectionInterface::callError方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::callError方法的具体用法?PHP ConnectionInterface::callError怎么用?PHP ConnectionInterface::callError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ratchet\ConnectionInterface的用法示例。


在下文中一共展示了ConnectionInterface::callError方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: dispatch

 public function dispatch(Conn $conn, $id, $topic, array $params)
 {
     $parts = explode("/", $topic->getId());
     if (count($parts) < 2) {
         $conn->callError($id, $topic, "Incorrectly formatted Topic name", array("topic_name" => $topic->getId()));
         return;
     }
     $handler = $this->getHandler($parts[0]);
     $method = $this->toCamelCase($parts[1]);
     $result = null;
     if ($handler) {
         try {
             $result = call_user_func(array($handler, $method), $conn, $params);
         } catch (\Exception $e) {
             $conn->callError($id, $topic, $e->getMessage(), array("code" => $e->getCode(), "rpc" => $topic->getId(), "params" => $params));
             return;
         }
         if ($result === null) {
             //incase handler doesnt return anything!
             $result = false;
         }
     }
     if ($result) {
         if (!is_array($result)) {
             $result = array($result);
         }
         $conn->callResult($id, $result);
         return;
     } elseif ($result === false) {
         $conn->callError($id, $topic, "RPC Failed", array("rpc" => $topic->getId(), "params" => $params));
     }
     $conn->callError($id, $topic, "Unable to find that command", array("rpc" => $topic->getId(), "params" => $params));
     return;
 }
开发者ID:medooch,项目名称:ClankBundle,代码行数:34,代码来源:RPCHandler.php

示例4: dispatch

 /**
  * @param ConnectionInterface $conn
  * @param string              $id
  * @param string              $topic
  * @param WampRequest         $request
  * @param array               $params
  */
 public function dispatch(ConnectionInterface $conn, $id, $topic, WampRequest $request, array $params)
 {
     $callback = $request->getRoute()->getCallback();
     try {
         $procedure = $this->rpcRegistry->getRpc($callback);
     } catch (\Exception $e) {
         $conn->callError($id, $topic, $e->getMessage(), ['rpc' => $topic, 'request' => $request]);
         return;
     }
     $method = $this->toCamelCase($request->getAttributes()->get('method'));
     $result = null;
     try {
         $result = call_user_func([$procedure, $method], $conn, $request, $params);
     } catch (\Exception $e) {
         $conn->callError($id, $topic, $e->getMessage(), ['code' => $e->getCode(), 'rpc' => $topic, 'params' => $params, 'request' => $request]);
         return;
     }
     if ($result === null) {
         $result = false;
     }
     if ($result) {
         if ($result instanceof RpcResponse) {
             $result = $result->getData();
         } elseif (!is_array($result)) {
             $result = [$result];
         }
         $conn->callResult($id, $result);
         return;
     } elseif ($result === false) {
         $conn->callError($id, $topic, 'RPC Error', ['rpc' => $topic, 'params' => $params, 'request' => $request]);
     }
     $conn->callError($id, $topic, 'Unable to find that command', ['rpc' => $topic->getId(), 'params' => $params, 'request' => $request]);
     return;
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:41,代码来源:RpcDispatcher.php

示例5: 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

示例6: onCall

 public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     // In this application if clients send data it's because the user hacked around in console
     $conn->callError($id, $topic, 'Calls not supported')->close();
 }
开发者ID:schnello,项目名称:volkszaehler.org,代码行数:5,代码来源:WampClientAdapter.php

示例7: onCall

 public function onCall(Conn $conn, $id, $topic, array $params)
 {
     $conn->callError($id, $topic, 'RPC not supported on this demo');
 }
开发者ID:gloubster,项目名称:server,代码行数:4,代码来源:WebsocketApplication.php

示例8: 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)
 {
     $conn->callError($id, $topic, 'You are not allowed to make calls');
 }
开发者ID:Bit-Wasp,项目名称:node-php,代码行数:10,代码来源:DebugPusher.php

示例9: onCall

 /**
  * An RPC call has been received
  *
  * @param \Ratchet\ConnectionInterface $conn
  * @param string                       $id     The unique ID of the RPC, required to respond to
  * @param string|Topic                 $topic  The topic to execute the call against
  * @param array                        $params Call parameters received from the client
  */
 function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     // In this application if clients send data it's because the user hacked around in console
     $conn->callError($id, $topic, 'You are not allowed to make calls')->close();
 }
开发者ID:BinaryStudioAcademy,项目名称:reviewr,代码行数:13,代码来源:BasePusher.php

示例10: onCall

 /**
  * An RPC call has been received.
  *
  * @param \Ratchet\ConnectionInterface $conn
  * @param string                       $id     The unique ID of the RPC, required to respond to
  * @param string|Topic                 $topic  The topic to execute the call against
  * @param array                        $params Call parameters received from the client
  */
 public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
 {
     $this->console->info('onCall');
     $conn->callError($id, $topic, 'You are not allowed to make calls')->close();
 }
开发者ID:askedio,项目名称:laravel-ratchet,代码行数:13,代码来源:Pusher.php

示例11: onCall

 public function onCall(Conn $from, $callId, $topic, array $params)
 {
     echo 'Received data from ' . $from->resourceId . "\n";
     if ($topic->getId() == 'api.call') {
         if (!isset($params['id']) || !is_int($params['id'])) {
             var_dump($params);
             $from->callError($callId, $topic, 'Bad request: invalid call id');
             return;
         }
         // Handle HTTP headers
         if (isset($params['http_headers']) && is_array($params['http_headers'])) {
             if (isset($params['http_headers']['Accept-Language'])) {
                 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $params['http_headers']['Accept-Language'];
             }
         }
         try {
             if (isset($params['groupped']) && $params['groupped'] == true) {
                 $resp = $this->_handleRequestGroup($from, $params['data']);
             } else {
                 $resp = $this->_handleRequest($from, $params['data']);
             }
         } catch (Exception $e) {
             $errMsg = $e->getMessage();
             $resp = new ApiResponse();
             $resp->setSuccess(false);
             $resp->setValue($errMsg);
             $resp->setChannel(2, $errMsg);
         }
         $resp->setId($params['id']);
         $respData = $resp->generateArray();
         echo 'Sending data to ' . $from->resourceId . "\n";
         $from->callResult($callId, $respData);
     } else {
         $from->callError($callId, $topic, 'Bad request: unsupported topic "' . $topic->getId() . '"');
     }
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:36,代码来源:ApiWebSocketServer.class.php

示例12: onCall

 /**
  * {@inheritdoc}
  */
 public function onCall(Conn $conn, $id, $topic, array $params)
 {
     $this->logger->error(sprintf('Received RPC call on topic %s', $topic->getId()), ['topic' => $topic]);
     $conn->callError($id, $topic, 'RPC not supported on this demo');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:8,代码来源:PhraseanetWampServer.php

示例13: 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::callError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。