2017 © Pedro Peláez
 

project websocketclient

websocket client lib

image

tansoft/websocketclient

websocket client lib

  • Friday, July 13, 2018
  • by tansoft
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Websocket Client for PHP

Simple websocket client and support data record and playback., (*1)

Depend on project Textalk/websocket., (*2)

Installing

Preferred way to install is with Composer., (*3)

composer require tansoft/websocketclient

Client usage:

require('vendor/autoload.php');

class MyHandler implements WebSocket\ISocketHandler{
    public function onConnect(&$client){
        //init send something
        $client->send($reg);
    }
    public function onReceive(&$client, $msg){
        //receive something with $msg
        //return false for exit
        return true;
    }
    public function onError(&$client, $errno, $errmsg){
        echo('socket error '.$errno.':'.$errmsg);
        //return true for auto reconnect
        return true;
    }
}

$client = new WebSocket\WebSocketClient('ws://echo.websocket.org/', new MyHandler);
//setup auto ack settings
$client->setupAck('{"event":"ping"}', '{"event":"pong"}', KEEPALIVE_TIMEOUT_SECOND);

//setup rawdata record
$client->setupRawLog('rawdata.log');
$client->loop();

//or

//setup rawdata playback
//use flag WebSocket\WebSocketClient::RAWLOG_PLAYBACKMODE_QUICK for playback with no sleep
$client->setupRawLog('rawdata.log', WebSocket\WebSocketClient::RAWLOG_PLAYBACKMODE_NORMAL);
$client->loop();

Changelog

1.0.0, (*4)

  • Support auto ack.
  • Support event base callback.
  • Support rawdata record and playback.

The Versions

13/07 2018

dev-master

9999999-dev

websocket client lib

  Sources   Download

MIT

The Requires

 

The Development Requires

websocket testcase replay

13/07 2018

1.0.1

1.0.1.0

websocket client lib

  Sources   Download

MIT

The Requires

 

The Development Requires

websocket testcase replay

20/06 2018

1.0.0

1.0.0.0

websocket client lib

  Sources   Download

MIT

The Requires

 

The Development Requires

websocket testcase replay