Skip to content

Commit ae78fff

Browse files
committed
Issue #37 Bytes are directly used instead of Uint8Array
1 parent 8b9a02f commit ae78fff

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

jetclient-js/src/jet-0.1.js

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
(function (jet) {
22
"use strict";
33

4-
var evts = new Uint8Array(128);
5-
// do initialization
6-
for (var i = 0; i < evts.length; i++) {
7-
evts[i] = i;
8-
}
9-
104
// Event code Constants
11-
jet.ANY = evts[0];
12-
jet.PROTOCOL_VERSION = evts[1];
5+
jet.ANY = 0x00;
6+
jet.PROTOCOL_VERSION = 0x01;
137

14-
jet.CONNECT = evts[2];
15-
jet.CONNECT_FAILED = evts[6];
16-
jet.LOG_IN = evts[8];
17-
jet.LOG_OUT = evts[10];
18-
jet.LOG_IN_SUCCESS = evts[11];
19-
jet.LOG_IN_FAILURE = evts[12];
20-
jet.LOG_OUT_SUCCESS = evts[14];
21-
jet.LOG_OUT_FAILURE = evts[15];
8+
jet.CONNECT = 0x02;
9+
jet.CONNECT_FAILED = 0x06;
10+
jet.LOG_IN = 0x08;
11+
jet.LOG_OUT = 0x0a;
12+
jet.LOG_IN_SUCCESS = 0x0b;
13+
jet.LOG_IN_FAILURE = 0x0c;
14+
jet.LOG_OUT_SUCCESS = 0x0e;
15+
jet.LOG_OUT_FAILURE = 0x0f;
2216

23-
jet.GAME_LIST = evts[16];
24-
jet.ROOM_LIST = evts[18];
25-
jet.GAME_ROOM_JOIN = evts[20];
26-
jet.GAME_ROOM_LEAVE = evts[22];
27-
jet.GAME_ROOM_JOIN_SUCCESS = evts[24];
28-
jet.GAME_ROOM_JOIN_FAILURE = evts[25];
17+
jet.GAME_LIST = 0x10;
18+
jet.ROOM_LIST = 0x12;
19+
jet.GAME_ROOM_JOIN = 0x14;
20+
jet.GAME_ROOM_LEAVE = 0x16;
21+
jet.GAME_ROOM_JOIN_SUCCESS = 0x18;
22+
jet.GAME_ROOM_JOIN_FAILURE = 0x19;
2923

30-
jet.START = evts[26];
31-
jet.STOP = evts[27];
32-
jet.SESSION_MESSAGE = evts[28];
33-
jet.NETWORK_MESSAGE = evts[29];
34-
jet.CHANGE_ATTRIBUTE = evts[32];
35-
jet.DISCONNECT = evts[34];// Use this one for handling close event of ws.
36-
jet.EXCEPTION = evts[36];
24+
//Event sent from server to client to start message sending from client to server.
25+
jet.START = 0x1a;
26+
// Event sent from server to client to stop messages from being sent to server.
27+
jet.STOP = 0x1b;
28+
// Incoming data from server or from another session.
29+
jet.SESSION_MESSAGE = 0x1c;
30+
// This event is used to send data from the current machine to remote server
31+
jet.NETWORK_MESSAGE = 0x1d;
32+
jet.CHANGE_ATTRIBUTE = 0x20;
33+
jet.DISCONNECT = 0x22;// Use this one for handling close event of ws.
34+
jet.EXCEPTION = 0x24;
3735

3836
// Functions
3937
// Creates a new event object

0 commit comments

Comments
 (0)