fpm-plugin-socketio
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dev
src
test
.babelrc
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
README.md
nodemon.json
package-lock.json
package.json

README.md

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 Functions
    • broadcast
    • 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)
      })