Application Messaging

The built-in functions are great, but sometimes you want to have custom logic running on the JNIOR.  This is a huge benefit of the JNIOR and being able to communicate directly with those applications from a web interface is uniquely powerful.  To take advantage of this feature we must have a unique ID assigned to the application we wish to communicate with.  The web application must make the first communication attempt to that application ID using the Post Message command.  Once that command has been sent, JANOS will subscribe this connection to receive further Reply Message messages from the Java application.  Application IDs must be greater than 1024 and must be unique.

Post Message

We use Post Message to send data from the Web Application to the Java Application.  JANOS will place the Content of the message on the internal Message Pump.  Each Java Application running on the JNIOR will examine application ID associated with the message.  If application owns the ID then the application will process the message.

    var message = { Message: 'status.get' };
    jnrwbsocket.postMessage(2010, message);

The above is an example of getting the status from the application when the web application first launches.  Again, this message will subscribe the web-socket to receive future Reply Messages from this application ID.

Note: You will receive all Reply Message messages from this application.  Event if it is a reply to another websocket connections message.  care must be given if you dont want this to happen.