rstream
v1.0.6
Published
## 如何使用
Downloads
3
Readme
#RStream 实时消息调度客户端
如何使用
安装RStream
npm install rstream
使用样例
import RStream from 'rstream';
const stream = new RStream({
server: 'http://localhost:3000',
token: 'test'
});
stream.on('connect_error',(error)=>{
console.log(error);
});
stream.on('error',(error)=>{
console.log(error);
});
stream.on('message',(message)=>{
console.log(message);
});
stream.on('connect',()=>{
stream.sendMessage({
to:'topdmc',
body:{}
});
});
stream.open();
TODO: message
message:
{
from:'', //来自appid
to:'', // 发送的appid
event:'message', //消息
sent:1000000, // 发送的时间戳
content:'', // 消息内容
createAt:'' //
}
Events
rstream_error
: RPC层的错误消息connect_error
: Fired upon a connection error. Parameters: Object error objectconnect_timeout
: Fired upon a connection timeout. reconnect. Fired upon a successful reconnection. Parameters: Number reconnection attempt numberreconnect_attempt
: Fired upon an attempt to reconnect.reconnecting
: Fired upon an attempt to reconnect. Parameters: Number reconnection attempt numberreconnect_error
: Fired upon a reconnection attempt error. Parameters: Object error objectreconnect_failed
: Fired when couldn't reconnect within reconnectionAttempts