ElephantIO / elephant.io

Send events to a socket.io server through PHP
https://elephantio.github.io/elephant.io/
MIT License
108 stars 34 forks source link

add socket.io's handshake.auth option #3

Closed laszlo-karpati closed 1 year ago

laszlo-karpati commented 1 year ago

This pull request adds support for Socket.io's handshake authentication feature, as outlined in the Socket.io documentation. The proposed changes ensure that Elephant.io can seamlessly integrate with Socket.io servers that require authentication during the handshake phase.

Usage example:

$engine = Client::engine(
    Client::CLIENT_4X,
    $socketAddress,
    [
        'auth' => [
            "token" => 'my_secret_token',
            "user" => 'admin@example.com',
        ],
    ]
);
$this->client = new Client($engine);
$this->client->initialize();