bazo/wamp-client

PHP WAMP 客户端

dev-master 2014-10-16 11:35 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:31:33 UTC


README

关于

此库已在 Ratchet WAMP 服务器上测试过。它只能向服务器发送消息,尚未实现监听回复。支持的功能

  • 前缀
  • 调用
  • 发布
  • 事件

基于 https://github.com/Wisembly/elephant.io

使用方法

$client = new \WAMP\WAMPClient('https://:8080');
$sessionId = $client->connect();

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

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

$data = [0, 1, 2];

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

publish an event

//$payload can be scalar or array
$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', $payload, $exclude, $eligible);

$client->event('topic', $payload);
$client->disconnect();

许可

本软件根据 MIT 许可证分发。有关更多信息,请参阅 LICENSE。

作者

Martin Bažík martin@bazo.sk

感谢

感谢 Elephant.IO 作者在 WebSocket 通信部分的贡献。