|
Version 1.0 |
|
| ||||||||||||
Java LibraryThe Java version of the XIMSS Client SDK is implemented as a XIMSSLib package.
The package defines the Session object (a XIMSS session) and its methods.
The Java XIMSS Client Library accepts "callback methods" specified as an Object reference and a String
specifying the object method name to invoke.
To use a static method as a callback method, specify the method Class reference as the Object reference.
If the client application does not need to be notified when a certain event takes place, it should specify null as a method name. package com.communigate.ximss; // // XIMSS Session object class // public class Session extends Object { public static String getVersion(); public static void create(HashMap<String,String> params, Object theRef, String createCallbackName) throws Exception; public void start(); public void sendRequest(org.w3c.dom.Element xmlRequest, Object theRef, String dataCallbackName, String finalCallbackName, boolean sendImmediately) throws Exception; public void close(Object theRef, String finalCallbackName) throws Exception; public boolean setAsyncProcessor(Object theRef, String asyncDataCallbackName, String tagName, String attrName, String attrValue) throws Exception; public boolean setNetworkErrorProcessor(Object theRef,String networkErrorCallbackName, int timeLimit) throws Exception; public boolean setNetworkOKProcessor(Object theRef,String networkOKCallbackName) throws Exception; public org.w3c.dom.Element createXMLNode(String tagName); public org.w3c.dom.Node createTextNode(String text); public static void setCallbackFactory(CallbackFactory newFactory); } // // Callback methods // void createCallback(Session newSession,String errorCode); void dataCallback(org.w3c.dom.Element xmlData,org.w3c.dom.Element xmlRequest); void finalCallback(String errorCode,org.w3c.dom.Element xmlRequest); Object asyncDataCallback(org.w3c.dom.Element xmlData); Boolean networkErrorCallback(Boolean isFatal,Integer tryingTimeInSeconds); void networkOKCallback(); In some GUI environments, such as Swing this is not acceptable, as the "callback" methods should be invoked from the "GUI threads" only - to allow the code of these methods to use the GUI functions. To accomodate for these restrictions use the setCallbackFactory static method with a "callback factory" implementing a platform-specific callback mechanism. The XIMSSLibSwing.jar package implements the swingCallbackFactory "factory" class for the Swing platform, and the XIMSSLibAndroid.jar package implements the androidCallbackFactory "factory" class for the Android platform. #import com.communigate.ximss.*; #import com.communigate.ximss.swingCallbackFactory.*; ... XIMSS.Session.setCallbackFactory(new swingCallbackFactory()); ... The networkErrorCallback and networkOKCallback callback methods are always called directly, using the Java XIMSS Client Library own processing thread. JavaScript LibraryThe JavaScript version of the XIMSS Client SDK is implemented as a single ximssclient.js file
stored in the stock CommuniGate Pro "Basic Skin" (its path is /SkinFiles//*/ximssclient.js).
The JavaScript version of the XIMSS Client Library accepts "callback methods" specified as an object reference and a function method reference. The specified method is invoked for the specified object. If the client application does not need to be notified when a certain event takes place, it should specify null as the method reference. This JavaScript file defines a XIMSSSession "constructor" function: // // XIMSSSession object constructor // function XIMSSSession(params,theRef,createCallback) { this.start = function() {...} this.sendRequest = function(xmlRequest,theRef,dataCallback,finalCallback,sendImmediately) {...} this.close = function(theRef,finalCallback) {...} this.setAsyncProcessor = function(theRef,asyncDataCallback,tagName,attrName,attrValue) {...} this.setNetworkErrorProcessor = function(theRef,networkErrorCallback,timeLimit) {...} this.createXMLNode = function(tagName) {...} this.createTextNode = function(text) {...} this.setDebugFunction = function(theRef,debugCallback) {...} } // "static" methods XIMSSSession.prototype.getVersion = function() {...} // // Callback methods // function createCallback(newSession,errorCode); function dataCallback(xmlData,xmlRequest); function finalCallback(errorCode,xmlRequest); function asyncDataCallback(xmlData); function networkErrorCallback(isFatal,tryingTimeInSeconds); function debugCallback(tag,debugString); Use the setDebugFunction method to set an object and its method to be used as an internal debugging facility. This method is called with 2 string parameters - the name of the internal library component and the log record text. Objective C LibraryThe Objective C version of the XIMSS Client SDK is implemented as a XIMSSSession class and its methods.
This class interface is defined in the XIMSSSession.h header file.
The libXIMSSMacOSX.a and libXIMSSiOS.a files include the class implementations.
The Objective C version of the XIMSS Client Library accepts "callback methods" specified as an object reference and a method selector. You can use the @selector(methodName) syntax construct to specify the method selector. The specified method is invoked for the specified object. To use a class method as a callback method, specify the method class as the "object reference". If the client application does not need to be notified when a certain event takes place, it should specify nil as a method selector. Since the iOS platforms do not include solid XML support, the XIMSS Client libraries for these platforms
include a basic XML object implementation.
// // XIMSSSession object Class // @interface XIMSSSession : NSObject { } +(NSString*)getVersion; +(void)create:(NSDictionary*)params delegate:(NSObject*)delegate onCompletion:(SEL)createCallbackSelector; -(void)start; -(void)sendRequest:(XIMSSXML*)xmlRequest delegate:(NSObject*)delegate onData:(SEL)dataCallbackSelector onCompletion:(SEL)finalCallbackSelector sendImmediately:(bool)doImmediately; -(void)close:(NSObject*)theRef onCompletion:(SEL)finalCallbackSelector; -(bool)setAsyncProcessor:(NSObject*)delegate selector:(SEL)asyncDataCallbackSelector tagName:(NSString*)tagName attrName:(NSString*)attrName attrValue:(NSString*)attrValue; -(bool)setNetworkErrorProcessor:(NSObject*)delegate selector:(SEL)networkErrorCallbackSelector timeLimit:(unsigned)timeLimit; -(bool)setNetworkOKProcessor:(NSObject*)delegate selector:(SEL)networkOKCallbackSelector; @end // // Callback methods // -(void)createCallback:(XIMSSSession*)newSession errorCode:(NSString*)errorCode; -(void)dataCallback:(XIMSSXML*)xmlData xmlRequest:(XIMSSXML*)xmlRequest); -(void)finalCallback:(NSString*)errorCode xmlRequest:(XIMSSXML*)xmlRequest; -(id)asyncDataCallback:(XIMSSXML*)xmlData; -(id)networkErrorCallback:(bool*)pIsFatal elapsedTime:(int*)pTryingTimeInSeconds; -(void)networkOKCallback; Note: networkErrorCallback should return a non-null value to . Note: when linking your application against the XIMSS Library, add the -ObjC flag to the application Other Linker Flags. Sessionless RequestsA client can perform certain operations without creating a XIMSS Session. To check the XIMSS Client Library version, the client application should use the getVersion static method. It returns a string with the Library version.Opening a XIMSS SessionA client starts communicating with a XIMSS Server by creating a XIMSS Session. Requests and response messages are sent within a context of that Session. The XIMSS Client SDK can support several independent XIMSS sessions - to the same Account or to different Accounts, on the same Server or on different Servers. To open a new XIMSS Session, the client application needs to use the create static method or the XIMSS Session constructor method. This method accepts the following parameters:
Starting a XIMSS SessionAfter a XIMSS Session object is created, it should be started using the start method.
Before this method is invoked, the client application should set all required processors (for asynchronous data messages, for network failures, etc.) When this method is invoked all asynchronous data messages received during the session creation operation are processed. Sending XIMSS RequestsA client application composes XIMSS requests as XML element objects and asks the Library
to send it to the server.
The client application should not specify the id attribute of the request -
it will be set within the Library.
If the Library provides the createXMLNode and createTextNode methods, these methods MUST be used to compose XIMSS requests. A composed XIMSS request should be submitted to the XIMSS Session object using the sendRequest method, with the following parameters:
A client application does not need to wait for a XIMSS request to complete (and for the finalCallback method to be called) before sending a new XIMSS request to the server. Processing Asynchronous XIMSS Data MessagesA client application can register objects and their method with a XIMSS session object,
so the Library will invoke these methods as "processors" for certain asynchronous data messages received from the server.
A client application should use the setAsyncProcessor method with the following parameters:
Processing Communication ProblemsA client application can register an object and its method with a XIMSS session object
using the setNetworkErrorProcessor method, and the Library will invoke that method when it encounters
network communication problems.
The Library invokes the specified method when it encounters a "fatal" error (such as a TCP connection reset)
and when it encounters a transient error (such as an HTTP transaction timeout).
A client application should use the setNetworkErrorProcessor method with the following parameters:
The specified method should return a boolean value.
If it returns true (for example, if the transient error condition is longer
than the application-specific limit, then the encountered error is treated as a fatal one.
When the Library encounters a fatal error, or if the Library encounters a transient error, but the registered networkErrorCallback method returned a true-value, the Library completes all pending XIMSS requests with the communication error completion code. The Library then closes the XIMSS Session. When the server terminates a XIMSS session, the situation is processed as a fatal communication problem. A client application can register an object and its method with a XIMSS session object using the setNetworkOKProcessor method, and the Library invokes this method when communication with the server is restored after the library has invoked the networkErrorCallback method. Closing a XIMSS SessionA client application can close a previously created XIMSS Session using the
close method with the following parameters:
CommuniGate Pro Guide. Copyright © 2020, AO StalkerSoft
|