Frame type 0 is used for generic remote procedure call - RPC. This method call is based on XML-RPC (s. http://www.xmlrpc.com/spec ). There is one xml file inside such frame which contains serialized procedure call.
This section contains description of various method which should be implemented. Most of them can be implemented by server and client, some of them only by one side. Method specification is written in pseudo "C" notation.
Every method call contains at least one parameter "ticker" - string. This parameter contains unique method call identification. Such identification can be used to pair together request and response. Every response have to also contain "ticker". Protocol is asynchronous and it is possible to send several independent requests at once.
Example 1. Example of method call in XMLRPC
<?xml version="1.0"?> <methodCall> <methodName>authorize</methodName> <params> <param> <value><string>ticker</string></value> </param> <param> <value><string>user</string></value> </param> <param> <value><string>password</string></value> </param> </params> </methodCall>
Method response is standard response as defined in XML-RPC. Each response has to contain as first parameter "ticker" which has to have same value as "ticker" send by caller. Example of metho response:
<?xml version="1.0"?> <methodResponse> <params> <param> <value><string>ticker</string></value> </param> <param> <value><i4>130</i4></value> </param> </params> </methodResponse>
First step is to introduce client to the server. There is method
called hello
.
Struct HelloData { // Application name string systemName; // Application version string systemVersion, // Array of supported options array options { struct Option { // Name of option string name; // Value of option string value; }; }; };
HelloData hello(string ticker, HelloData
data);
Returns informations about server and its protocol implementation.
Note
For compatibility with older clients server should be able to
communicate without hello
call. Older client will start
communication with method authorize
.
List of options:
- REQUEST_TASKLIST
-
This is server extension. Server should send it to the client if supports method
requestTaskList
. Value have to be 1. If server does not support this extension option is not sent or value is set to 0. - FOLDERS
-
This extension requires support on server and client. Both sides have to be notified about folder support. If side does not support this extension option is not sent or value is set to 0.
- AUTHORIZE2
-
This is protocol extension. Server should send it to the client if supports method
authorize2
. Value has to be 1. If server does not support this extension option is not sent or value is set to 0. Client can use methodauthorize2
only when it is supported by server. - STOREDOCUMENT
-
Store document extension requires support on server and client. Both sides has to be notified about STOREDOCUMENT support. Default value is 0. Value has to be set to 1 when server or client want to use
errorStoreDocument
notification or send extended error messages in SaveDocument structure. - SESSION_BOUND_DOCUMENT
-
Both sides has to be notified about SESSION_BOUND_DOCUMENT support. Documents can be bound to the session. When connection is closed all session bound documents are also closed.
When this feature is on documents can be send with the session specific flag, look at method
pushDocument
. When any documents in the client is closed notificationonCloseDocument
is sent.
Next step to establish a connection is to authorized client. This
can be done by calling method authorize
or
authorize2
.
Simple authorization by username and plaintext password.
int authorize(string ticker, string user, string
password);
Return value is number. List of error codes is in the following table
Table 4. authorize, List of Error Codes
Error Code | Description |
---|---|
0 | authorized |
1 | wrong name or password |
2 | other error in login |
3 | rejected by server (user with same user and password is already connected from another computer) |
Extended authorization. Authorize user by username and password encrypted by selected method. (Compatibility notice AUTHORIZE2)
AuthorizeResponse authorize2(string ticker, string method,
string user, string password);
Table 5. authorize parameters
Parameter | Description |
---|---|
method | authentication method (method of password encryption) |
user | user name |
password | password |
Table 6. authentication methods
Method | Description |
---|---|
plain | plain text password |
external-token | external token ( send token provided by external application as password ) |
Return value is structure containing error code and error description. Set errorCode to 0 when authorization process was successfull.
/* AuthorizeResponse description */ struct AuthorizeResponse { /* error code 0-OK, >0 - fail*/ int errorCode; /* string containing error description message */ string errorDescription; }
Method setState
allows to change
connection state. Directly after authorization only one way
communication is allowed (client to server). Server can send message to
the client only when connection is in state '1' (default state after
connection is '0').
void setState(string ticker, int iNewState);
Table 7. Set State, possible values
Value | Description |
---|---|
0 | default state, method like pushObject and pushDocument are not allowed |
1 | allow to receive objects, documents, ... |
It is possible to call remote functions. There is method named
callFunction
.
FunctionResponse callFunction(string ticker, string
functionName, strina parameter);
Table 8. call parameters
Parameter | Description |
---|---|
functionName | name of remote function |
parameter | Parameter of the function. Format of the parameter depends on the function. JSON serialized object is usually used |
Method callFunction return result of the remote
function.
/* call response structure */ Struct FunctionResponse { /* error code 0-OK, >0 - fail*/ int errorCode; /* string with data /* if error code if OK, it contains function specific data, * usually JSON object * if error code >0 then data contains error description */ string data; }
Protocol has API for object transfer. Objects are quite generic mechanism. It is possible to use them for Client to Server and also for Server to Client communication. Each object has a type and set of attributes.
/* Object description / Struct Object { /* Object type */ string type; /* Array of object attributes */ array attributes { /* One attribute */ struct Attribute { /* Attribute name */ string name; /* Attribute value */ string value; }; }; };
Object is send using method pushObject
.
void pushObject(ticker, Object);
Method will send object. There is no return value for this method. Value can be returned by another object send in oposite direction.
Document is collection of pages and attributes. Protocol allows to transfer such documents.
Structure Document
is usually used to
send/receive document.
/* Document description */ Struct Document { /* Unique document identifacator */ string documentId; /* Document version. Every document * can have more versions. */ string version; /* Document version. This is identification * of subversion on server side. Client can * safely ignore this value and have to just * send it back to server. */ string serverVersion; /* Document type. Document type define which * attributes are valid for document, how-to * display document and organize in logical * structure. Every document have to have * valid type. */ string type; /* Document modification. * 0 – document is not modified * 1 – document attributes are modified */ int modified; /* Document attributes. Array of document * attributes. Used attributes depens on document type */ array attributes { /* Structure describes one attribute */ struct Attribute { /* Attribute name */ string name; /* Attribute value */ string value; }; }; /* Array of files, pages. */ array files { /* Structure describing one file, page */ struct File { /* Unique file (page) identifacator */ string ident; /* File mime-type. */ string mimeType; /* Page importance. * 0 – page is not important * 1 – page is important */ int important; /* Page modification. * 0 – page is not modified * 1 – page attributes are modified * 2 – page data modified * 3 – page attributes and data modified */ int modified; /* Page number */ int pageNumber; /* Page notes or comments. */ string note; /* Original filename. */ string origName; /* Keys for page decryption/encryption. */ string keys; /* Page signature. */ string signature; }; }; };
Document can be send from server to client using method
pushDocument
.
void pushDocument(string ticker, Document document, int
state);
Client receiving this method call should display received document. Document can be in read-only or with full access rights.
Table 9. pushDocument, parameters
Parameter | Description |
---|---|
| Document |
| Document flags (can be combined):
|
Note
Pushed document can have pre-set attribute
modified
and client should properly interpret this
attribute.
Note
It is possible to send page without defined mime-type. It is
useful when mime-type definition is obtain from the document store
together with binary data. Such mime-type is send together with data
- look in section Frame Type 1. Instead of real type
mime-type Tahiti/Attrs+Bin
have to be
set.
Client can request document using method
getDocument
.
GetDocumentResponse getDocument(string ticker, string
docId, string version, int state);
Table 10. getDocument, parameters
Parameter | Description |
---|---|
docId | document identifier |
version | requested version, empty string means last version is requested |
state | request mode (0 - read-only, 1 - read/write) |
Method will return structure GetDocumentResponse
.
Requested document will be send using method
pushDocument
(the section called “Push Document”).
struct GetDocumentResponse { string ticker; int retCode; string version; }
Item retCode
is 0 if success. If method
failed item retCode
will be greater then
0.
Item version
contains returned version (
can be used to pair pushDocument
with this
request ).
Changed or new document is saved using method
saveDocument
. Save operation is done in three
steps:
-
Send new/changed document to the server. Server have to allocate new identifiers and send them to the client.
-
Send binary data files
-
Server have to send confirmation to the client about succesfull save opertaion.
Example 2. SaveDocument structure definition
/* Structure with newly allocated * Identifiers, new version */ Struct SaveDocument { /* Document state: * 0 – ok, * 1 – lock, * 2 – document not up2date, * 3 – error * 4 - error with detail, error details are stored * in version and serverVersion fields */ int state; /* Document identifier. This is unique * document identifier. If new document * is saved server has to generate this * identifier. When error is returned this field is * empty string */ string documentId; /* Identifier of new document version. * Each document version has unique combination of * docId and version. * * Error message is stored here when state is 4. * This message will be shown in UI to user. */ string version; /* Identifier of new server version. * Server version is used by optimistic * server locks. * * Detailed error message is stored here when state * is 4. This message will be logged on client side * and/or shown as detail or error. */ string serverVersion; /* List of new Identifiers for files. */ array<string> NewFileIdents; };
Function for saving new document or new version:
SaveDocument saveDocument(string ticker, Document
document);
Structure Document is parameter of the funcion. All requested items have to be correctly filled in the structure. Document identifier is empty string if document is saved for first time (new document). Server will return new document identifier.
Page identifiers are set only for existing unmodified pages. If page is modified or new identifier is empty string.
Function will return list of new file identifiers and identifier of new document. Server behavioure:
-
If document is requested from the server when newer version is saved last saved version will be returned.
-
If client is trying to save new version of the document in parallel with other client lock error have to be returned. Document is unlock on succesfull save operation, on error or on time-out.
Compatibility notice: error state 4 is valid only when STOREDOCUMENT is set to 1.
Notification about succefull save operation:
void receivedDocument(string ticker, string documentId,
string documentVersion);
Function has no return value and is used only for client notification.
When error occur in the save operation client is notified with
method errorReceivedDocument
or
errorStoreDocument
void errorReceivedDocument(string ticker, string
documentId, string documentVersion, int reason);
Function has no return value and is used only for client notification. Parametr reason is used to signal error code:
Table 11. errorReceivedDocument parameters
Parameters | Description |
---|---|
documentId | id of document |
documentVersion | version of document |
reason | reason of fail, error code |
void errorStoreDocument(string ticker, string
documentId, string version, int reason, string errorMessage,
string errorDetail);
Function has no return value and is used only for client notification. Compatibility notice STOREDOCUMENT
Table 13. errorReceivedDocument parameters
Parameters | Description |
---|---|
documentId | id of document |
documentVersion | version of document |
reason | reason of fail, error code |
errorMessage | error message to be presented in UI. Valid only when reason is 4. |
errorDetail | detailed error message. Valid only when reason is 4. |
Table 14. reason, list of error codes
Error Code | Description |
---|---|
1 | lock |
2 | document not up2date |
3 | error |
4 | error with description, parameters errorMessage and errorDetails are used. |
Existing document can be deleted using method
deleteDocument
. Function has parameter document id as
parameter.
int deleteDocument(string ticker, string
documentId);
Function return 0 if success, 1 - document is locked, 2 - no permissions, 3 - other error
Methods for file transfer.
File from server can be requested using method
requestFile
. When server receive such request it has to
send page to the client. File is send in frame type 1 (Frame Type 1).
void requestFile(string ticker, string
fileId);
Table 15. pushDocument, parameters
Parameter | Description |
---|---|
| File ID (Identifier). This ID have to be unique. |
If file is not available server can send notification
requestFileFailed
(the section called “Failed File Request”).
If file request (the section called “Request File”) failed other
side should send response requestFileFailed
. It is up to
the caller to correctly display this error to the user.
void requestFileFailed(string ticker, string fileId, int
errorCode, string description);
Parameter fileId
is unique file identifier.
Parameter errorCode
is error code.
Parameter description
is error description.
Configuration file can be requested using method
requestConfig
. Method will send configuration
file to the client. File is send as frame, type 2.
void requestConfig(string ticker, string
fileId);
If file is not available server can send notification
requestFileFailed
(the section called “Failed Config Request”).
Configuration file can be updated/requested using method requestConfig2.
void requestConfig2(string ticker, string fileId, string
fileHash, string hashType)
Method will send configuration file if hash of the configuration
file on the server is different from the hash of the current
configuration file on the client. File is send as frame type 2. Server
have to send new configuration file or respond
errorRequestConfig
. Method
errorRequestConfig
is used to signal that
current configuration is up-to-date (errorCode
is set to 0) or to signal wrong request
(errorCode
greater then 0 ).
Table 17. requestConfig2, parameters
Parameter | Description |
---|---|
fileId | configuration identifier |
fileHash | Hash of configuration file stored on client. |
hashType | Type of function used to compute hash of configuration file. The only posible value is md5 for now. |
Example 3. requestConfig2 example
requestConfig2("ticker", "config.zip", "fcd66e666a77a18ca8d08c24f40bc439", "md5");
Example requests file config.zip
.
If configuration file does not exists or some other error occur server should send followinf notification about error.
void errorRequestConfig(string ticker, string fileId, int
errorCode);
Table 18. errorRequestConfig, parameters
Parameter | Description |
---|---|
fileId | file identifier |
errorCode | error code
|
Methods for task management.
Method requestTaskList
can be used to
request list of tasks.
void requestTaskList(string ticker, array<string>
tasks);
Parameter tasks
is list of currently available taks
on the client.
Server can send list of tasks to the client using method
pushTaskList
.
void pushTaskList(string ticker, array<string>
tasks, int flag);
Parametr tasks
is list of tasks. Flag values are in
the following table:
Table 19. flag, List of tasks
Flag | Description |
---|---|
1 | Full List - this is full list of all tasks.
Client should drop old list and use this one. This is also
response on |
2 | Additional List - tasks in the list should be added to the existing list |
Total number of displayed tasks on the client can be limitied in the server configuration. Tasks which client sent to the server in the requestTaskList and are not part of the response are not valid anymore and client have to delete them from UI.
Specific task can be requested using method
requestTask
.
void requestTask(string ticker, string
taskId);
Method request task from the server. Way of sending task to the
client is up to server implementation, common way is to use method
pushDocument
. Server can notify about error in task
request using method errorRequestTask
.
void errorRequestTask(string ticker, string
taskId);
Documents can be organized in the tree structure. There is API to manipulate with this tree ( create, change, remove folders, add items ,.. ).
Folders are quite similiar to folders on file system. Each folder has name (only root folder is empty string) and contains items. Item is document or another folder.
Methods allows to open folder. Client will receive for opened folder notifications about changes. Notifications are send until the folder is closed (the section called “Close Folder”).
Folder openFolder(string ticker, string
folderId);
struct Folder { // Status of folder // -3 - no permission to open // -2 - folder is locked // -1 - folder not exists // 0 - ok int status; // Items in the folder array items { struct FolderItem { // Type // 0 - folder, 1 - document int type; // Item id // id of folder or id of document string itemId; // Item name string name; }; }; };
Close folder. Closing folder will also stop sending notifications about folder changes.
void closeFolder(string ticker, string
folderId);
Client (subscriber) will receive notification about folder changes. Following notifications are available:
-
new item in the folder
-
item was removed from the folder (or item was moved to another folder)
-
item was renamed
void updateItem(string ticker, string folderId, int oper,
FolderItem item);
Function has three parameters: path, type of change, item with new data.
Possible types:
- 0
-
New item
- 1
-
Item was removed ( is no longer in the folder )
- 2
-
Item was renamed (docId is same with the original)
Folder or item can be renamed using method
renameItem
.
int renameItem(string ticker, string parentFolderId,
string itemId, string name);
parentFolderId is id of the folder.
Return values: 0 - ok, 1 - wrong id, 2 - no permissions, 3 - other error
New document is added to the tree calling
bindDocument
. Document have to be saved
before it can be add to the tree.
int bindDocument(string ticker, string parentFolderId,
string name, string docId);
Return values: 0 - ok, 1 - wrong id, 2 - no permissions, 3 - other error
It is possible to move any tree item to another folder. Method also allows to remove item from the tree.
int moveItem(string ticker, string parentFolderId, string
itemId, string newFolderId);
parentFolderId
is id of the original
folder
newFolderId
is id of new folder. If this
parameter is empty string item will be removed from the tree.
Return values: 0 - ok, 1 - wrong id, 2 - no permissions, 3 - other error
Before disconnect it is possible to notify other side about this
event calling method disconnect
.
void disconnect(int iReason, string
description);
Reason of disconnect is in parameter iReason
. List of
possible reasons is in the table bellow.
Table 20. disconnect, parameters
Constant | Description |
---|---|
0 | timeout |
1 | ukonceni aplikace |
2 | jiný důvod, popis je uveden v proměnné description |