Push-Services are able to inform the active users about urgend messages. The core of a push-service is a message queue. Senders are putting new messages into the message queue and receivers are getting messages from the message queue. Of course the user-applications are not directly working with the message queue, they use have API's accordingly.
The senders into the message queue can be:
- log protocols of applications
- from a node.js server
- from a browser
- from an app
- messages entered by users
- from a browser
- from an app
- updates for application
- from administrators, packed in the browser
- send by the server
The receivers can be users with a browser or users of an app.
The receivers can define filters - they may not be interested in every kind of messages - the sender too can restrict the potential receivers by using the co-reader functionality or defining other filters. REMARK: the first edition of push services will not have filters, except on channels.
A good metaphor for the design of a push service is a "channel". Channels bundle different kinds of messages, a starter will be:
- userchannel - messages from users for other users
- systemchannel - messages from the administrator to all active users, e.g. to warn from a shutdown
- loggingchannel - messages from applications, intended for analysis by developers
- updatechannel - messages from the administrator containing update packages that will be installed silently and automatically, primarily for app-users but may be for browser-users too (although a message to refesh the browser would have the same effect)
A dev-op-question is, if the push-service should be installed as external cloud service, as integrated part of the application or as separate installation side by side to ninas travel app server. The starter will be the separat server with some api's - and that means cross domain access must be allowed for the browser and the app.
The api's for the applications are:
- putmessage (former: putlog, POST) - client sends message to the push-server, the server puts the message into the queue and begins pushing
- pullmessage (former: pull, GET) - client requests new messages, a longwait is used to delay the response, if no messages are available, a longwait is done and if the client then receives no message he has to call pullmessage again, the client tool can use a longwait for polling.
A message that is transferred has the following data:
- channel - primary filter for messages, point-notation possible to differentiate
- level1 - title or short form of the message
- level2 - long form of the message
- severity - numeric, to be defined, serious starting at 3
- timestamp - timestamp from the client, numeric
- tscreated - timestamp from the server, numeric
- ip - address of the client, calculated on node.js
- username - from the client, sender
The coding on the server is rather straightforward, on the client it's more complicated, because it shall not interfere with the rest of the app or the browser application and the longpolling has to be executed on the client.
The basic solution of the past only knew one channel als filter, now a list of channels has to be processed.
The messages received have to be stored locally in the Browser or the App as the server only delivers new messages after the initial request.
And:
- a counter ("#pushcount" for pushmessageCount) for the pushmessages has to be implemented and updated
- if browser-mode the message has to be displayed in the footer area
- otherwise in app-mode a temporary popup is necessary
- and the message goes into the list with prependTo as "last in first out", that was the first approach, but the usability is better if the newest messages show up in the bottom above the entry area for chats
- additionally the state of the push-server connection is displayed with color
- green - connected
- yellow - trying to reconnect
- red - connection is lost
The layout of display for chat will be:
- list of messages on top
- position to last element, when new element is added
- entry area under the list area
This approach was not successful in the layout on different platforms. The entry area was put into the footer and then the scroll of the list to the last element did not work as expected.
http://stackoverflow.com/questions/6215779/scroll-if-element-is-not-visible
Regarding updates some design point already have been worked out:
The basic Ideas for downloading the updates are:
- using a special channel for downloading the updates
- the channel is activated when an app registers to the server
- when an update arrives
- the update is stored
- the update is checked if the activation is flagged
- when the activation is flagged the updates are done
- the details will be specified later
Chat will be another function based on push messages. Chat too is specified separately.
more to come