Coder Social home page Coder Social logo

woketo's Introduction

Woketo

A PHP WebSocket library. With following features:

  • 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

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 ! ๐Ÿ™€

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:

<?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 [email protected]: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.

You can read more about the installation of Autobahn on their documentation.

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.

What Woketo does not do?

Currently there is no support of the following:

  • 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).

<3

woketo's People

Contributors

nek- avatar folliked avatar valanz avatar awkan avatar vlacour97 avatar loru avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.