Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
msokk edited this page Feb 16, 2011 · 10 revisions

Module developing rules

Server side

  1. Go to /modules
  2. Must export "types" array to specify requests to be caught
  3. Also must export "init" function which is called with "this" being the socket client and with argument "data", which contains the whole payload from client
  4. There are 4 options to push data :
    • this.send(msg) - msg is sent back to originating client
    • this.broadcast(msg) - msg is sent to everybody except originating client
    • this.listener.broadcast(msg) - msg is sent to everybody
    • this.listener.announce(msg) - msg is sent to everybody (even anonymous users)

Client side

  • Go to /public/modules
  • Subscribe to events with Smog.on(type, callback) - callback gets data variable
  • Add filters with Smog.filter(name, callback) - callback gets input string
  • Same event/filter can't be redefined
  • Events can be removed with Smog.die(type)
  • Filters can be removed with Smog.removeFilter(name)

Used libraries

connect

socket.io

colors.js - for Admin tool

Clone this wiki locally