If you are not familiar with how to work against a space we recommend you read a simple introduction before you proceed.
The client has been tested and proved to work at the following browsers:
There are two ways to get up and running; The "custom way" and the "easy way". If your project already are depending on one of the libraries CometD have bindings to (Dojo Kit or jQuery), the "custom way" are the part you want to dive into. If you have no existing library and just want to get up and running, the "easy way" are the part you should read.
The CometD module are not part of the core functionality in these libraries and must therfore be installed in the library of choice.
TODO: complete description....
For your convenience the SemiSpace Comet package come with prepared builds of DojoKit and jQuery where the CometD module have been applied. To get started, select one of the provided prebuilt libraries for your project.
To use Dojo Kit for communication with the SemiSpace server, include Dojo Kit:
To use jQuery for communication with the SemiSpace server, include jQuery:
The init method can take a connection configuration object. This object are similar to the CometD configuration.
If you run on a default setup there should be no need to provide a connection configuration to the init method. The most needed parameter in the configuration to override will probably be URL the server. To override the server URL you provide a config object to the init method as follow:
When a initialization are done you can connect by executing the connection method:
It's possible to disconnect from the server by executing the disconnect method:
It is also possible to listen in on the communication between the client (browser) and the server. This can be used to get valuable information on what is going on in the browser when communicating with the server. It can also be used to provide status messages to the user on what is going on.
You listen in on the communication by providing a callback function to the meta listener method:
A popular pattern is to listen in on the status codes and provide the user with information on the connection to the server.
The status codes are as follow
|1||Handshake is done. The client has contacted the server but no connection are set up yet|
|2||The client are now connected to the server. Data can now be excanged with the server|
|3||The client was connected to the server but has lost connection to the server|
|4||The client communicates with the server. This will occur pretty frequently since the client pings the server from time to time|
|5||The client was disconnected from the server by the disconnect method|
|6||The client has subscribed to a CometD metachannel|
|7||The client has unsubscribed from a CometD metachannel|
|8||The client has published a message to the server|
|9||The client tried to publish a message to the server but failed|
TODO: remember release function on notify
A note on handling JSON
Each JSON object transmitted to the space must be stringified before sent.