MikolaNika
MikolaNika

Reputation: 11

PHPSocket.io emit message from PHP to PHP

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.

Upvotes: 1

Views: 197

Answers (0)

Related Questions