Unichat notifications

Whenever something happen on the server, it notifies relevant clients about it by sending the notification.

Receiving notifications

The client side receives notifications in the RPC it could provide. The signature of the noticiation target should be (javascript example, in localInterface object):

onNotificationReceived: function({notifications:...}) {

This function, it presented in localInterface will be called by the server each time a relevant event occur. The functions receives notifications named argument, and recevies named argument notifcations with array of notification records explained below.

Notification data

Each notification has 3 mandatory fields:

  • event: could be new, changed, or deleted, or some exotic types discussed later on.
  • object_type: the type of the referenced object
  • object: the referenced object with minimum information about it, as we want to reduce the size of the events stream. Client can load object in full details with corresponding API methods as need.

Here is the real world example:

  "notifications": [
      "event": "new",
      "object_type": "message",
      "object": {
        "id": 8,
        "user_id": 72,
        "group_id": 2,
        "deleted_at": null,
        "serial": 8,
        "text": "hello world ;)",
        "edited_at": null,
        "created_at": "2018-10-15T17:54:41Z"

Note that notifications come in Array, most often, of 1 element size. Still it may happen to have more than 1. In that case, first item of the array represent the most old notification, and the last - the most recent one.

Special notifications

Events that are not just changed state of some object are described here.

"entering": user enters text

Is emitted to all group participants when some user saved a draft of a message to his subscription. To trigger it. just save currently entered text into a draft in the subscription. Client software should do it by the inactivity timer when user has entered/changed anything in the chat message fileld.

Notification has following format:

        event:       "entering",
        object_name: "no matter", // ignore it
        object: {
            user_id:383,          // user who is typing message
            group_id:78           // group where it occurs

is_online or is_offline: user status.


        event:       "is_online",
        object_name: "user",
        object: {