This chapter describes how to develop a client to receive X-PUSH messages (nexacro Platform 17.1 Application). X-PUSH client can be configured with the nexacro application. Therefore, in order to develop an X-PUSH client, knowledge of nexacro application development is required.
This document does not describe nexacro application development but only specifics related to the X-PUSH server. For detailed information related to application development, please refer to the nexacro Platform Manual.
nexacro17.1 Client Development
X-PUSH client can be developed with nexacro application. Basically, to receive messages through the X-PUSH server, the X-PUSH protocol adapter must be added and it can be configured through an object.
- X-PUSH Protocol Adapter
In nexacro Platform, an X-PUSH protocol adapter is included in the basic package.
All functions of xpush 2.8 and higher versions are supported from nexacro 17.1. Some functions may not be available in nexacro 17.
Adding X-PUSH Object to nexacro Project
Follow the steps below to add the X-Push object to the project.
Select "TypeDefinition"-"Objects" in the Project Explorer window, click the right mouse button, and select "Edit".
Press the + button to select the Push.json file and click Open.
Select the + button in Objects to select nexacro.XPush and click OK.
Check whether the added X-PUSH object is properly registered.
Protocol Adapter Attributes
The following attribute values can be changed.
Attribute | Format | Default | Description |
---|---|---|---|
ControlRetry | number | 5 | A command can be sent to the X-PUSH server by calling the Command() method. If an error occurs when requesting the "AddF" and "DelF" commands, the specified value is retried. |
Debug | boolean | false | Determine whether to display Push messages (true/false) on the nexacro Studio output window. |
IPList | string | N/A | Register one or more X-PUSH servers. The adapter randomly selects from among registered servers and tries to connect. If the connection with the selected server is not made, it tries to connect again by selecting randomly from the servers except the failed server. The server is registered in the following format. [X-PUSH server IP: Port],… ex) "192.168.1.1:10081,192.168.1.2:10081" |
KeepAliveTime | number | 30 (seconds) | In order to maintain the connection with the X-PUSH server, messages must be sent to the X-PUSH server at regular intervals. The time interval can be set in seconds. |
KeepTimeOut | number | 60 (seconds) | The time to wait for a response from a message sent to the X-PUSH server is set to maintain the connection. |
LayoutURL | string | N/A | Set the path of the message layout definition file. This attribute value must be set. The following methods are allowed when setting the path. • The following aliases can be used. %System%, %ProgramFiles%, %Tobe%, %Windows% %Component%, %USERAPP% • AppGroup can be used. Hence, the cache function of AppGroup can be used. {AppGroup}::file • URL is supported. protocol://host/file protocol://host:port/file protocol://file … (Currently, only "file", "http", and "https" protocols are available) |
projectID | string | N/A | Set the project name to be used when communicating with the X-PUSH server. |
protocolversion | number | 2 | Set the Protocol version to be used when communicating with the X-PUSH server. 2.8 version or higher: 3 2.6 version or lower: 2 |
Retry | number | The value set in the registry | It sets the number of reconnections when connecting to the X-PUSH server. If the adapter fails to connect with the X-PUSH server, it tries to connect as much as this value. If not set, the value set in the registry is used. |
SessionID | string | N/A | It sets the SessionID to be used when connecting to the X-PUSH server. If SessionID is not set when calling the CyPushAdp.Connect() method, the value specified in the attribute value is used. The two values passed when the X-PUSH server requests the authentication to the Authenticator are UserID and SessinID. |
TimeOut | number | The value set in the registry | It sets the TimeOut value when communicating with the X-PUSH server. If not set, the value set in the registry is used. |
UserID | string | N/A | It sets the UserID used when connecting to X-PUSH server. If UserID is not set when calling the CyPushAdp.Connect() method, the specified attribute value is used. |
Protocol Adapter Event Attributes
Events generated from the xpush adapter can be defined.
onerror | The event generated when the operation request to the xpush server fails |
onkeepalive | The event generated when packets are sent and received at regular intervals to maintain the connection with the xpush server |
onsuccess | The event generated when the operation request to the xpush server is successful |
Examples
Functional Example Application
Location: %XPUSH_HOME%/sample/nexacro_client
The project file of the example application is %XPUSH_HOME%\sample\nexacro_client\xpushSample.xadl. Open this file in nexacro Studio.
Click [File > Open > Project] in the nexacro Studio menu.
Select the example project, xpushSample.xprj file.
Double-click sample01_functional under Base in the Project Explorer window.
The functions and codes used in the example are described below.
Only English language letters and standard numerals are available for all input values other than messages.
set_projectid, set_protocolversion
Set the project_id information.
this.XPush00.set_projectid("PRO#1");
Set the protocol version to communicate with x-push.
this.XPush00.set_protocolversion('3');
connection
Connect with X-PUSH server.
{ var value = this.IpPort.value; this.XPush00.set_iplist(value); this.XPush00.connect("user00","pw"); }
| |
sUserID | User ID |
sPassword | User password |
subscribe
Register Topic Type and Topic Id on X-PUSH server.
{ var ret = this.XPush00.subscribe(this.topicTYPE.value, this.topicID.value, this, this.dsMessage, "append", "fn_PushCallback_Test_Data"); } /* * Callback function (Receiving message) */ this.fn_PushCallback_Test_Data = function (Row, ChangeColumn, AllColumns, Type, ActionType, MessageId) { trace("fn_PushCallback - NOTI\n" + " - ActionType : " + ActionType + "\n" + " - Row : " + Row + "\n" + " - MessageId : " + MessageId + "\n" ); trace(this.dsMessage.saveXML() ); /* * Receiving a generic message */ if (ActionType == "PUSH") { trace(this.dsMessage.getColumn(0, "NOTI_00")); trace(this.dsMessage.getColumn(0, "NOTI_01")); trace(this.dsMessage.getColumn(Row, "NOTI_02")); trace(this.dsMessage.getColumn(Row, "NOTI_03")); } /* * Receiving a reliable message */ if (ActionType == "RELI") { trace(this.dsMessage.getColumn(0, "NOTI_00")); trace(this.dsMessage.getColumn(0, "NOTI_01")); trace(this.dsMessage.getColumn(0, "NOTI_22")); } }
| |
sMessageType | Topic Type |
sMessageId | Topic Id |
this | Current form |
this.dsOperation | DataSet |
"update" | Method of reflecting received message to the data set |
"fn_PushCallback_Test_Data" | Callback function Receiving X-PUSH message Differentiating generic message (PUSH) and reliable message (RELI) with ActionType |
Inquiring the Number of Unreceived Messages
Request the number of unreceived messages from the X-PUSH server.
this.btnReqd_onclick = function(obj:Button, e:nexacro.ClickEventInfo)
{
this.XPush00.requestMessageCount("NOTI", "ALL");
}
| |
"NOTI" | Topic Type |
"ALL" | Topic Id |
Success Failure | Success: Check in onsuccess (action==10) Failure: Check in onerror (action==10) |
Requesting the Unreceived Messages
Request the unreceived messages from the X-PUSH server.
this.btnReqd_onclick = function(obj:Button, e:nexacro.ClickEventInfo)
{
this.XPush00.requestMessage("NOTI", "ALL");
}
| |
"NOTI" | Topic Type |
"ALL" | Topic Id |
Success Failure | Success: Check in onsuccess (reason == 6) Failure: Check in onerror (errorcode == -902) |
Sending Receipt Confirmed Messages
Send a receipt confirmed message to X-PUSH when a reliable message is received from the X-PUSH server.
this.fn_PushCallback_Test_Data = function(Row, ChangeColumn, AllColumn, Type, ActionType, MessageId)
{
AddLog("get push data. reliable message = " + "[ActionType:" + ActionType + "] " + this.dsMessage.getColumn(0, "Title"));
if (ActionType == "RELI") {
alert(this.dsMessage.getColumn(0, "Title"));
this.XPush00.sendResponse(MessageId);
}
}
| |
MessageId | The ID of received reliable message |
Success Failure | Success: Check in onsuccess (reason == 5) Failure: Check in onerror (errorcode == -901) |
User Registration
Add user information (T_TOPIC Table) to the database. User registration (ADUI) must take place after authentication (AUTH).
this.XPush00.registerTopic("NOTI", "ALL");
this.XPush00.registerTopic("NOTI", "ALL"); | |
"NOTI" | Topic Type |
"ALL" | Topic Id |
Success Failure | Success: Check in onsuccess (action == 8) Failure: Check in onerror (action == 8) |
User Deletion
Delete user information (T_TOPIC Table) from the database.
this.XPush00.unregisterTopic("NOTI", "ALL");
this.XPush00.unregisterTopic("NOTI", "ALL"); | |
"NOTI" | Topic Type |
"ALL" | Topic Id |
Success Failure | Success: Check in onsuccess (action == 9) Failure: Check in onerror (action == 9) |
Success/Failure Event Processing
onerror
this.XPush00_onerror = function(obj:XPush, e:XPushErrorEventInfo) { this.fn_setMsg("XPush00_onerror Event\n" + " - eventid: " + e.eventid + "\n" + " - action: " + e.action + "\n" + " - statuscode: " + e.statuscode + "\n" + " - errormsg: " + e.errormsg + "\n" + " - serverip: " + e.serverip + "\n" + " - serverport: " + e.serverport + "\n" + " - e.message: " + e.message + "\n" + " - e.command : " + e.command ); if (e.command != null) { this.fn_setMsg("e.command != null\n" + " - e.command.check : " + e.command.check + "\n" + " - e.command.row : " + e.command.row + "\n" + " - e.command.type : " + e.command.type + "\n" + " - e.command.useactiveformcallback : " + e.command.useactiveformcallback + "\n" + " - e.command.actiontype : " + e.command.actiontype + "\n" + " - e.command.callback : " + e.command.callback + "\n" + " - e.command.messagekey : " + e.command.messagekey + "\n" + " - e.command.messagetype : " + e.command.messagetype + "\n" + " - e.command.objdataset : " + e.command.objdataset + "\n" + " - e.command.objform : " + e.command.objform); } if (e.message != null) { this.fn_setMsg("e.message != null\n" + " - e.message.messagetype: " + e.message.messagetype + "\n" + " - e.message.messagekey: " + e.message.messagekey + "\n" + " - e.message.messageid: " + e.message.messageid + "\n" + " - e.message.devicetoken: " + e.message.devicetoken); } this.fn_setMsg("e.returnvalue : " + e.returnvalue); }
| |
e.action | XPushAction.AUTH (0) - connect() XPushAction.BYEC (1) - disconnect() XPushAction.ADDF (2) - subscribe() XPushAction.DELF (3) - unsubscribe() XPushAction.REQD (4) - requestMessage() XPushAction.RECT (5) - sendResponse() XPushAction.RGST (6) - reqisterDevice() XPushAction.UNRG (7) - unreqisterDevice() XPushAction.ADUI (8) - reqisterUser() XPushAction.UNUI (9) - unreqisterUser() XPushAction.MSGC (10) - requestMessageCount() |
e.statuscode | -100 - Push server sent “Byec” or is terminated according to the agreement with the server. -101 – Timeout processed. -200 - Command Auth Error. An error occurred in authentication for the currently selected IP. -201 – All connections to the Push server registered in the iplist attribute have failed. -202 - An error occurred in the data transmission channel authentication. -300 – Failed to connect to the server. -301 – A packet transmission (send/recv) error occurred. -401 – Failed to disconnect X-PUSH server. -501 - Failed to suspend message reception from X-PUSH server. -601 - Failed to resume message reception from X-PUSH server. -701 - Failed to register/unregister topic to X-PUSH server. -801 -Message format version information not matched. -901 - Failed to send receipt response to the reliable message. -902 – Unreceived message request failed. -1001 - Failed to register mobile DeviceToken information to the X-PUSH server. -1002 – A request of user topic information reqisterUser to X-PUSH server failed. -1003 - A request of user topic information X-PUSH unregisterUser to X-PUSH server failed. -1004 - Unreceived message information request failed. |
onsuccess
this.XPush00_onsuccess = function(obj:XPush, e:XPushEventInfo) { alert("XPush00_onsuccess Event\n" + " - eventid: " + e.eventid + "\n" + " - statuscode: " + e.statuscode + "\n" + " - errormsg: " + e.errormsg + "\n" + " - reason: " + e.reason + "\n" + " - action: " + e.action + "\n" + " - serverip: " + e.serverip + "\n" + " - serverport: " + e.serverport + "\n" + " - e.message: " + e.message + "\n" + " - e.command : " + e.command + "\n" + " - e.returnvalue : " + e.returnvalue); if (e.command != null) { alert("e.command != null\n" + " - e.command.check : " + e.command.check + "\n" + " - e.command.row : " + e.command.row + "\n" + " - e.command.type : " + e.command.type + "\n" + " - e.command.useactiveformcallback : " + e.command.useactiveformcallback + "\n" + " - e.command.actiontype : " + e.command.actiontype + "\n" + " - e.command.callback : " + e.command.callback + "\n" + " - e.command.messagekey : " + e.command.messagekey + "\n" + " - e.command.messagetype : " + e.command.messagetype + "\n" + " - e.command.objdataset : " + e.command.objdataset + "\n" + " - e.command.objform : " + e.command.objform); } if (e.message != null) { alert("e.message != null\n" + " - e.message.messagetype: " + e.message.messagetype + "\n" + " - e.message.messagekey: " + e.message.messagekey + "\n" + " - e.message.messageid: " + e.message.messageid + "\n" + " - e.message.returnvalue: " + e.message.returnvalue + "\n" + " - e.message.devicetoken: " + e.message.devicetoken); if(e.message.returnvalue != undefined || e.message.returnvalue != null) { var returnvalue = e.message.returnvalue; for(var i = 0; i < returnvalue.length; i++) { alert("index:" + i + " : " + returnvalue[i].topictype + " : " + returnvalue[i].topicid + " : " + returnvalue[i].count); } } } }
| |
e.action | XPushAction.AUTH (0) - connect() XPushAction.BYEC (1) - disconnect() XPushAction.ADDF (2) - subscribe() XPushAction.DELF (3) - unsubscribe() XPushAction.REQD (4) - requestMessage() XPushAction.RECT (5) - sendResponse() XPushAction.RGST (6) - registerDevice() XPushAction.UNRG (7) - unregisterDevice() XPushAction.ADUI (8) - registerTopic() XPushAction.UNUI (9) - unregisterTopic() XPushAction.MSGC (10) - requestMessageCount() |