PHP code example of aguetkriegerisch / elephant.io-custom
1. Go to this page and download the library: Download aguetkriegerisch/elephant.io-custom library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aguetkriegerisch / elephant.io-custom example snippets
use ElephantIO\Client;
$url = 'http://localhost:8080';
$client = new Client(Client::engine(Client::CLIENT_4X, $url));
$client->initialize();
$client->of('/');
// emit an event to the server
$data = ['username' => 'my-user'];
$client->emit('get-user-info', $data);
// wait an event to arrive
// beware when waiting for response from server, the script may be killed if
// PHP max_execution_time is reached
if ($packet = $client->wait('user-info')) {
// an event has been received, the result will be a stdClass
// data property contains the first argument
// args property contains array of arguments, [$data, ...]
$data = $packet->data;
$args = $packet->args;
// access data
$email = $data['email'];
}