Exemple #1
3
<?php

require "socket.io.php";
$message = isset($_GET['msg']) ? $_GET['msg'] : "Hora ! PHP S4A ! :)";
$send2 = ["message" => $message, "key" => "@pp2007ws:)"];
$socketio = new SocketIO('127.0.0.1', 1337);
if ($socketio->send('message', json_encode($send2))) {
    echo json_encode($send2);
} else {
    echo 'Sorry, we have a mistake :\'(';
}
<?php

include_once 'socket.io.php';
//Create a socket.io connection and send a simple message
$socketio = new SocketIO();
if ($socketio->send('localhost', 9090, 'Hello world!')) {
    echo 'we sent the message and disconnected';
} else {
    echo 'Sorry, we have a mistake :\'(';
}