2017 © Pedro Peláez
 

library bolt

Asynchronous WebSocket client

image

calcinai/bolt

Asynchronous WebSocket client

  • Tuesday, May 29, 2018
  • by calcinai
  • Repository
  • 2 Watchers
  • 5 Stars
  • 126 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

bolt

Asynchronous WebSocket client client library for PHP. Supports HyBi, ~~as well as Hixie #76~~ (no point)., (*1)

This was built purely to be a client, as the majority of the WS clients available also contain servers and are very bloated., (*2)

Installation

Using composer:, (*3)

composer require calcinai/bolt   

Usage

Since this really lends itself to being an asynchronous app, it is built to use the React event loops and resolver since there's a good chance they'll be in your project already and this lets you attach to the same loop., (*4)

$loop = \React\EventLoop\Factory::create();
$dns_factory = new React\Dns\Resolver\Factory();
$resolver = $dns_factory->createCached('8.8.8.8', $loop);

$client = new \Calcinai\Bolt\Client('ws://127.0.0.1:1337/chat', $loop, $resolver);

//Most WS servers will complain/forbid if there is no origin header
$client->setOrigin('127.0.0.1');

$client->connect();


$client->on('stateChange', function($newState){
    echo "State changed to: $newState\n";
});

$client->on('message', function($message) use ($client){
    echo "New message: \n";
    echo $message;

    $client->send('This is a response message');
});

$loop->run();

Other available events are connecting, connect, disconnecting, disconnect, (*5)

HTTP basic auth is also supported via the URI inf the form user:pass@host, (*6)

Any feedback is most welcome, (*7)

The Versions

29/05 2018

dev-master

9999999-dev

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michael Calcinai

29/05 2018

v1.0.1

1.0.1.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michael Calcinai

28/05 2018

v1.0.0

1.0.0.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michael Calcinai

01/12 2015

v0.1.4

0.1.4.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

by Michael Calcinai

01/12 2015

v0.1.3

0.1.3.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

by Michael Calcinai

22/10 2015

v0.1.2

0.1.2.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

by Michael Calcinai

20/10 2015

v0.1.1

0.1.1.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

by Michael Calcinai

16/10 2015

v0.1.0

0.1.0.0

Asynchronous WebSocket client

  Sources   Download

MIT

The Requires

 

by Michael Calcinai