Giter Site home page Giter Site logo

yunba-php-sdk's Introduction

Yunba PHP SDK

Yunba (http://yunba.io) SDK PHP版。

API说明

构造器

$yunba = new Yunba(array $setup);

参数:

  • array $setup 配置选项,包括:
    • server(可选) - 服务器域名或IP
    • port(可选)- 服务器端口
    • appkey - 应用AppKey字符串
    • debug(可选)- 是否开启调试模式

初始化

$yunba->init($initCallback = null, $recCallback = null);

参数:

  • callable $initCallback 初始化结果回调函数
  • $recCallback 重新连接回调函数

连接服务

$yunba->connect($callback = null);

参数

  • callable $callback 连接成功或失败回调函数

断开连接

$yunba->disconnect($callback = null);

参数

  • callable $callback 回调函数

触发事件

$yunba->emit($event, array $args, $callback = null);

参数:

  • string $event 事件名
  • array $args 参数
  • callable $callback 回调函数

监听事件

$yunba->on($event, $callback);

参数:

  • string $event 事件名
  • callable $callback 回调函数

订阅

$yunba->subscribe (array $args, $subscribeCallback = null, $messageCallback = null);

参数:

  • array $args 参数,包括topic, qos两个选项
  • callable $subscribeCallback 订阅结果回调函数
  • callable $messageCallback 消息接收回调函数

取消订阅

$yunba->unsubscribe (array $args, $callback = null);

参数:

  • array $args 参数,包括topic一个选项
  • callable $callback 回调函数

发布消息

$yunba->publish (array $args, $callback = null);

参数:

  • array $args 要发布的消息的内容,包括topic, msg, qos三个选项
  • callable $callback 回调函数

等待和服务间的通讯

$yunba->wait();

使用示例

请见 examples/subscribe.php 和 examples/publish.php

yunba-php-sdk's People

Contributors

tigerzhang avatar

Watchers

 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.