Skip to content
chernser edited this page Sep 22, 2012 · 2 revisions

DummyAPI notifications are based on Socket.io library and support handling in two directions: from server, to server.

Current topic is about basics of notifications.

Resource Instance Events

Any changes of any resource instance trigger sending events to client. By default next events are send for corresponding changes in resources:

  1. resource_created - resource instance is created.
  2. resource_updates - resource instance is changed.
  3. resource_deleted - resource instance is removed.

Affected resource instance is sent as body of event.

Tuning Resource Instance Events

For sure, your application "understands" differ events, than DummyAPI sends. To tune events triggered by resource changes use proxy function. It is set on the "To Client" tab of notifications panel.

Notifications Proxy Function - is triggered to pre-process event object before sending it to client. It can tune name and body of the event. Proxy function gets event object as first parameter and data as second. Result of it should be event object:

  { 
     name: String, // event name 
     type: 'msg' || 'event', // type of response 
     data: Any, // event body
  }

Event object passed to function contains default name and type.

NOTE: proxy function MUST have name 'proxy'

Sending Notifications

You can send custom notification to selected client by full filling "Send Notifications" form.

Sniffing Events

Switch to "From Client" tab of Notifications panel to see what events your application is sending to a server.