PHPSocket.io emit message from PHP to PHP

185 Views Asked by At

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.

0

There are 0 best solutions below