IM API Specification DocumentChanges in IM API documentation
Changes in IM API
Contents
PurposeIM API is an interface for sending and receiving instant messages. IM API is intended for those user applications, which need this kind of functionality, e.g. games. From a functionality point of view IM API can be divided as follows:
API descriptionThe logical type of IM API is Library API. IM API provides standalone implementation classes that are used by the client. The interface provides methods that do not block, but return immediately, so that the API operation happens simultaneously while the client application continues to run. The implementation is used in the context of the client’s thread and the operations can be used independently of each other. Notification events are used to indicate the client of changes in the connection state and on arrival of a new instant message. Moreover, when some operation is complete, the client also gets a notification of this. The API implementation uses active objects so the client application is required to install and run an active scheduler. API class structure
IM API is divided into two logical parts: connection handling and IM handling.
Each part has its observer interface, which needs to be implemented by the
client. The user application first has to create an object of
Related APIs
Using IM APIIn order to use IM API, the client has to create a connection using an own unique application ID and log in to the remote IM server. After creating the interface objects, the user application has to register its observers using the corresponding method from each interface class. This is necessary because the methods of this API are non-blocking and the notification when the operation is complete is delivered through the observer methods. Each asynchronous operation returns an operation ID when the request is issued. When the operation ends, the observer method is called with the operation ID to map it back to the corresponding request. Creating the connection and registering the observer
Creating
The client application has to have an application ID, which is supposed
to be unique in the domain of the application using the instant messaging
services. The application ID is given in the
An application ID can be defined as a literal, e.g.:
Example code:
Related APIs
Logging in
After the
Example code:
The
Related APIs
Canceling the ongoing loginIf the login operation is not yet finished, there is a possibility to cancel it. If the login was not yet started or it is finished already the method will leave with an appropriate error code. The method is asynchronous and will complete by calling the corresponding observer method.
The
Example code:
Related APIs
Logging outAfter a successful login the connection can be closed by starting a logout procedure. If calling the method when not logged in it will leave with an appropriate error code. The method is asynchronous and will complete by calling the corresponding observer method.
Example code:
Related APIs
Unregistering the connection observerBy unregistering the connection observer all the connection related ongoing tasks are cancelled. It is advised that when login is ongoing or already logged in, first cancel the login, or logout before unregistering the connection observer. Creating IM client and registering the observer
Creating the
The
Example code:
Before using the methods in the
Example code:
Related APIs
Sending a point-to-point message
Sending a point-to-point message is possible by using a user ID (e.g. WV
user ID) or contact model ID from the contacts DB. In the latter case the
IM API translates the recipient’s address to the corresponding protocol user
ID. In case the contact ID given in the method does not have a user ID in
its fields, the error code
In case there are more contact IDs in the recipient list and for example
one does not have a user ID, this one is silently removed from the list and
a message sending is attempted to the other recipients. In case the recipient
was addressed directly with a user ID the validity of the ID is checked only
in the remote IMPS server. Therefore the error code can be delivered only
to the observer object by the
It is not possible to send several point-to-point messages in the same
active object scheduling round, e.g. calling
The
This method returns an operation ID. Please note that only one message
can be sent during an active object scheduling round, which means for example
that the
Example code: Example code of sending with contact IDs
Example code of sending with user IDs:
Example code:
Example code:
Related APIs
Receiving a point-to-point message
New point-to-point messages are delivered to the IM observer method
Example code: Example code for textual messages
Related APIs
Receiving partial success
In case that one or more user IDs were incorrect for some reason
Related APIs
Memory and error handlingGlossaryAbbreviations
Definitions
|