Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在google app engine上部署Ratchet服务器并监听_Php_Sockets_Google App Engine_Websocket_Ratchet - Fatal编程技术网

Php 在google app engine上部署Ratchet服务器并监听

Php 在google app engine上部署Ratchet服务器并监听,php,sockets,google-app-engine,websocket,ratchet,Php,Sockets,Google App Engine,Websocket,Ratchet,我正在创建一个ratchet聊天应用程序。它目前在我的本地主机8080上,但是我想将它连接到我的google app engine项目,我能做什么 这是我的棘轮代码: class Chat implements MessageComponentInterface { protected $clients; public function __construct() { $this->clients = new \SplObject

我正在创建一个ratchet聊天应用程序。它目前在我的本地主机8080上,但是我想将它连接到我的google app engine项目,我能做什么

这是我的棘轮代码:

class Chat implements MessageComponentInterface {

        protected $clients;

        public function __construct() {
            $this->clients = new \SplObjectStorage;
        }

        public function onOpen(ConnectionInterface $conn) {
            // Store the new connection to send messages to later
            $this->clients->attach($conn);

            echo "New connection! ({$conn->resourceId})\n";
        }

        public function onMessage(ConnectionInterface $from, $msg) {
            $numRecv = count($this->clients) - 1;
            echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n"
                , $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');

    foreach ($this->clients as $client) {
        if ($from !== $client) {
            // The sender is not the receiver, send to each client connected
            $client->send($msg . " Hello ");
        }
    }
}

public function onClose(ConnectionInterface $conn) {
    // The connection is closed, remove it, as we can no longer send it messages
    $this->clients->detach($conn);

    echo "Connection {$conn->resourceId} has disconnected\n";
}

public function onError(ConnectionInterface $conn, \Exception $e) {
    echo "An error has occurred: {$e->getMessage()}\n";

    $conn->close();
}
}


$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new Chat()
        )
    ),
    8080
);
$server->run();
AppEngine是否支持这一点?如果不支持,我可以使用哪些其他替代方案在实时应用程序上部署聊天