Skip to content

hugohenrique/Pawl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Pawl

An asynchronous PHP WebSocket client. (early alpha)


<?php

    require __DIR__ . '/vendor/autoload.php';

    $loop = React\EventLoop\Factory::create();
    $connector = new Ratchet\Client\Factory($loop);

    $connector('ws://127.0.0.1:8080')->then(
        function(Ratchet\Client\WebSocket $conn) {
            $conn->on('message', function($msg) {
                echo "Received: {$msg}\n";
            });

            $conn->send('Hello World!');
        },
        function($e) use ($loop) {
            echo "Could not connect: {$e->getMessage()}\n";
            $loop->stop();
        }
    );

    $loop->run();

About

Asynchronous WebSocket client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%