phpsocket.io发出从PHP到PHP的消息
我正在尝试将消息从php代码发射到使用phpsocket.io构建的WebSocket服务器 发射器代码:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$emitter = new Emitter();
$emitter->in(1)->emit('update', array('message' => 'OK'));
服务器代码:
$this->server->on('connection', function (Socket $socket) {
$socket->on("update", function () use ($socket) {
// Called only when sent from real client
});
});
正如我所看到的,发射器无法将消息发送给PHP,所有消息都直接发送给客户端。我想在('Connection')函数上接收$ $ this-&gt; server-&gt; of meagess的消息,因为我想在将数据发送给客户端之前要处理。
I'm trying to emit message from PHP code to websocket server built with PHPSocket.io
Emitter code:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$emitter = new Emitter();
$emitter->in(1)->emit('update', array('message' => 'OK'));
Server code:
$this->server->on('connection', function (Socket $socket) {
$socket->on("update", function () use ($socket) {
// Called only when sent from real client
});
});
As I saw, emitter can't send messages to PHP, all messages are going directly to client. I want to receive message in $this->server->on('connection')
function, as I want to process data before sending it to client.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论