|
1 | | -This is a javascript client project for [jetserver](https://github.com/menacher/java-game-server/tree/master/jetserver) library. An example html which can connecct to a locally running Jetserver is located at src/test/jetclient.html . |
| 1 | +This is a **Javascript** client project for [jetserver](https://github.com/menacher/java-game-server/tree/master/jetserver) library. An example html which can connect to a locally running Jetserver is located at **test/jetclient.html**. |
2 | 2 |
|
3 | 3 | About the Client |
4 | 4 | ================ |
5 | | -Click on `start war` button after loading jetclient.html in a websocket enabled browser to start the game. Assumption is that JetServer is running and jetclient.html is using accurate hostname and port number. |
| 5 | +Click on `Start War!` button after loading jetclient.html in a websocket compatible browser to start the game. Assumption is that Jetserver is running and jetclient.html is using accurate hostname and port number. |
6 | 6 |
|
7 | 7 | Usage as your own game client |
8 | 8 | ============================= |
9 | 9 | The general usage steps could be as outlined below. |
10 | | -1. Create a config object containing the username, password and connectionkey to connect to game room. If you are using a different protocol, then add the appropriate codec chains also to the config object. By default JSon encoding/decoding is used. |
11 | | -2. Create a session using the session factory by passing in a url for the remote jetserver, config object and a callback function which will receive the session object after successful login to remote jeteserver. |
12 | | -3. Create as many sessions as required using this factory. Generally only one is required for a client. In the example 50 sessions are created. |
13 | | -4. Add necessary handlers to the session using `addHandler` function. The default events generated are provided the jet.Events class. At the very least you would want to add a handler for the jet.Events.SESSION_MESSAGE event to receive incoming events from jetserver. |
| 10 | +1. Create a `config` object containing the `user`, `password` and `connectionkey` to connect to game room. If you are using a different protocol, then add the appropriate `CodeChain`'s also to the `config` object. By default `JSon` encoding/decoding is used. |
| 11 | +2. Create a `session`(s) using the `SessionFactory` by passing in a `url` for the remote jetserver, `config` object and a `callback` function which will receive the `session` object after successful login to remote jeteserver. |
| 12 | +3. Add necessary handlers to the session using `addHandler` function. The default events are provided the `jet` class for e.g `jet.lOG_IN`. At the very least you would want to add a handler for the `jet.SESSION_MESSAGE` event to receive incoming events from jetserver. |
| 13 | +4. Event objects to be sent to server can be created using the `jet.nevent` function. |
14 | 14 | 5. Data can be send to remote server using `session.send` function. |
15 | 15 |
|
16 | 16 | Happy Coding!! |
|
0 commit comments