Spacebrew/spacebrew.js — pull request #11 by quinkennedy (2014-03-21 17:00:33+00:00)
Title: added targetType enum to direct messages to admin/client

fix for https://github.com/Spacebrew/spacebrew/issues/48 prompted by https://github.com/Spacebrew/spacebrew.js/pull/10

This adds a targetType enum which can be used to explicitly identify whether messages are targeted to clients or admins. The complicated scenario necessitating this type of clarity is:

1. A webpage registers a Client "Button" with publisher "click" and subscriber "click"
* That same webpage registers an Admin over the same Websocket connection
* The Client publishes a message `{"message":{"clientName":"Button", "name":"click", "value":True, "type":"boolean"}}`
* The SB Server sends a message to all Admins to notify them of the message: `{"message":{"clientName":"Button", "name":"click", "value":True, "type":"boolean"}}`
* Is the message directed at the Admin or the subscriber "click" for Client "Button"?

Now the Admin-directed message will be: `{"targetType":"admin", "message":{"clientName":"Button", "name":"click", "value":True, "type":"boolean"}}` while the subscriber-directed message will remain: `{"message":{"clientName":"Button", "name":"click", "value":True, "type":"boolean"}}`