Skip to content

Latest commit

 

History

History
86 lines (57 loc) · 1.81 KB

API.md

File metadata and controls

86 lines (57 loc) · 1.81 KB

Prism Server API

Server()

Prism Server

Example:

  var server = new Server({
    root:          '/my/app/dir',
    dir:           'services',
    log:           console.log,
    transport:     require('rtt-engineio')(),
    events:        instanceOfAnEventEmitter,
    sessionStore:  new RedisStore({port: 6379}),
    cacheSessions: true
  });

Server.service(name:String, service:Object, options:Object)

Use a Realtime Service

Examples:

  server.service('rpc', require('rts-rpc')())

Server.use(middleware:Function)

Use pre-request middleware for rate limiting, message sanitizing etc

Works exactly like Express/Connect middleware

Examples:

  server.use(require('ss-rate-limiter'));

Server.browserAssets()

Returns a list of all files which need to be sent to the browser

Server.buildClient()

Builds a custom client module which includes the client-side transport and service code you need

Server.publicServices()

Returns an array of non-private services which should be sent to the client

Server.process(an:Object)

Process Incoming Request from a Realtime Transport

Examples:

  server.process({message: '1|{"method": "callMe"}', socketId: 1234});

Server.start(Callback:Function)

Start Server

Examples:

  server.start(function() {
    console.log("Realtime Server started on port %s", server.port);
  });