1.1.0 • Published 5 years ago
fpm-plugin-socketio v1.1.0
fpm-plugin-socketio
the socketio plugin for fpm
Basic Info
- Run Action Hook Name:
BEFORE_SERVER_START
- ExtendModule Name:
socketio
- Exception
E.SocketIO.CLIENT_OFFLINE
{ errno: -10001, code: 'CLIENT_OFFLINE', message: 'The Client Id Not Online' } ```
getDependencies()
[]
- The Reference Of The
Bind()
Method An BizModule Object Contains 2 Functionsbroadcast
send
Usage
Broadcast message
fpm.execute('socketio.broadcast', message!Object) => Promise
- It always return a resolved Promise { data: 1}
Send message to The client
fpm.execute('socketio.send', message!Object) => Promise
- message must contains a 'id' , otherwise it return a rejected promise
WARNNING The topic should be replace of the args.topic.
Subscribe Event To Receive Message
#socketio/connect
fpm.subscribe('#socketio/connect', (topic, data) => { console.info(data.id) }) ```
#socketio/disconnect
fpm.subscribe('#socketio/disconnect', (topic, data) => { console.info(data.id) }) ```
#socketio/message
fpm.subscribe('#socketio/message', (topic, data) => { console.info(data.id, data.data) }) ```