2017 © Pedro Peláez
 

library woketo

image

nekland/woketo

  • Monday, June 4, 2018
  • by Nek
  • Repository
  • 8 Watchers
  • 26 Stars
  • 280 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 7 Open issues
  • 12 Versions
  • 9 % Grown

The README.md

Woketo

⚠️ Due to the lack of usage (barely nobody use it), this I will not make the effort to make it compatible with PHP 8. Therefore this library is deprecated and you should not use it. ⚠️, (*1)

A PHP WebSocket library. With following features:, (*2)

  • Server
  • Client
  • WSS Support (WebSocket over SSL)
  • Autobahn test suite passed (WebSocket test suite reference)
  • Binary/text messages supported
  • Built on top of reactphp (async socket communication)
  • Not dependent of any other big framework/library which mean you can use it with guzzle (any version) or Symfony (any version)
  • Woketo follows semver

Build Status Scrutinizer Code Quality Code Coverage, (*3)

Requirements

  • PHP 7+

How to install

# The installation is pretty much easier with composer. But you still can use it as git submodule !
composer require "nekland/woketo"

And that's all ! :scream_cat:, (*4)

How to use it

The file tests.php is a basic echo server. That's all you need to make a websocket server with Woketo:, (*5)

<?php

use Your\Namespace\YourMessageHandler;
use Nekland\Woketo\Server\WebSocketServer;

$server = new WebSocketServer(1337);
$server->setMessageHandler(new YourMessageHandler(), '/path'); // accessible on ws://127.0.0.1:1337/path
$server->start(); // And that's all <3
<?php
// YourMessageHandler.php

namespace Your\Namespace;

use Nekland\Woketo\Core\AbstractConnection;
use Nekland\Woketo\Message\TextMessageHandler;

class YourMessageHandler extends TextMessageHandler
{
    public function onConnection(AbstractConnection $connection)
    {
        // Doing something when the client is connected ?
        // This method is totally optional.
    }

    public function onMessage(string $data, AbstractConnection $connection)
    {
        // Sending back the received data
        $connection->write($data);
    }

    public function onDisconnect(AbstractConnection $connection)
    {
        // Doing something when the connection between client/server is disconnecting
        // Optionnal
    }
}

How to test

Unit tests suite

git clone git@github.com:Nekland/Woketo
cd Woketo
composer install
./bin/phpunit

Functionnal tests suite

Server test suite

php tests/echo-server.php
wstest -m fuzzingclient

Client test suite

wstest -m fuzzingserver
php tests/client_autobahn.php

wstest is the Autobahn test tool. You can install it with sudo pip install autobahntestsuite., (*6)

You can read more about the installation of Autobahn on their documentation., (*7)

How to something else?

  • How to learn more about Woketo usage? RTFM!
  • How to get information about how it works internally? Read the docs/dev.md page of doc.
  • How to contribute? Read the CONTRIBUTING.md page of doc.
  • How to get support? Use Gitter, the issue tracker is not a forum.

What's next?

You can see what's planned for next versions in the github milestones., (*8)

What Woketo does not do?

Currently there is no support of the following:, (*9)

  • WebSocket extensions, currently not supported but will probably be in the future
  • WAMP implementation will probably never be done by Woketo itself as it's a layer on top of WebSockets. This includes JSON-RPC and other layers up to WebSockets.

Thanks

Thank you to all code contributors (Hello folliked =)). And to any code reviewer (Hi valanz)., (*10)

<3, (*11)

The Versions

19/02 2018

dev-doc/update-woketo-support

dev-doc/update-woketo-support

  Sources   Download

MIT

The Requires

 

The Development Requires

19/02 2018
27/07 2017

dev-feature/use-standard-pack-unpack-functions

dev-feature/use-standard-pack-unpack-functions

  Sources   Download

MIT

The Requires

 

The Development Requires

05/06 2017
02/11 2016

dev-refactor/split-frame-building

dev-refactor/split-frame-building

  Sources   Download

MIT

The Requires

 

The Development Requires