2017 © Pedro Peláez
 

library websocket-client

WAMP client in PHP

image

gos/websocket-client

WAMP client in PHP

  • Monday, September 21, 2015
  • by ProPheT777
  • Repository
  • 4 Watchers
  • 13 Stars
  • 229,875 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 27 % Grown

The README.md

NOTE - This repository is deprecated, future releases will only be made for critical bugs and security vulnerabilities. Use Pawl instead., (*1)

WebSocketPhpClient

Latest Stable Version Latest Unstable Version Total Downloads License, (*2)

About

This package provides a PHP client that can send messages to a websocket server utilizing the WAMPv1 protocol. Listening for replies is not supported at this time., (*3)

Supported functions: - prefix - call - publish - event, (*4)

Usage

Directly Create A Client

You can directly create a Gos\Component\WebSocketClient\Wamp\ClientInterface instance by creating a new Gos\Component\WebSocketClient\Wamp\Client object. The constructor has two mandatory requirements; the server host and port. You may review the Client class constructor to see all arguments., (*5)

<?php
use Gos\Component\WebSocketClient\Wamp\Client;

$client = new Client('127.0.0.1', 8080);

Through The Factory

A Gos\Component\WebSocketClient\Wamp\ClientFactoryInterface is available to create client instances as well. The default Gos\Component\WebSocketClient\Wamp\ClientFactory supports a PSR-3 logger and will automatically inject it into the client if one is present., (*6)

<?php
use Gos\Component\WebSocketClient\Wamp\ClientFactory;

$factory = new ClientFactory(['host' => '127.0.0.1', 'port' => 8080]);
$client = $factory->createConnection();

Interact With Server

Once you have created a client, you can connect and interact with your websocket server., (*7)

<?php
use Gos\Component\WebSocketClient\Wamp\ClientFactory;

$factory = new ClientFactory(['host' => '127.0.0.1', 'port' => 8080]);
$client = $factory->createConnection();

$sessionId = $client->connect();

// Establish a prefix on server
$client->prefix('calc', 'http://example.com/simple/calc#');

// You can send an arbitrary number of arguments
$client->call('calc', 12, 14, 15);

$data = [0, 1, 2];

// Or an array
$client->call('calc', $data);

$exclude = [$sessionId]; // No sense in sending the payload to ourselves
$eligible = []; // List of other clients ids that are eligible to receive this payload

$client->publish('topic', '', $exclude, $eligible);

// Publish an event
$client->event('topic', '');
$client->disconnect();

License

This software is distributed under MIT License. See LICENSE for more info., (*8)

Original Project

https://github.com/bazo/wamp-client, (*9)

The Versions

21/09 2015

dev-master

9999999-dev

WAMP client in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Johann Saunier

websocket wamp ratchet

04/08 2015

v0.1.2

0.1.2.0

WAMP client in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Johann Saunier

websocket wamp ratchet

27/06 2015

v0.1.1

0.1.1.0

WAMP client in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Johann Saunier

websocket wamp ratchet

28/02 2015

v0.1.0

0.1.0.0

WAMP client in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Johann Saunier

websocket wamp ratchet