-
Notifications
You must be signed in to change notification settings - Fork 0
/
imp.js
43 lines (37 loc) · 1.03 KB
/
imp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.pragma library
function connectToServer(socket) {
console.log("connecting to server")
socket.active = true;
}
function connectToGame(socket) {
socket.sendTextMessage('{"type": "join","teamName": "TeamAhma"}')
console.log("connect send")
}
function serverConnected(ev) {
ev.serverConnected();
}
function exitGame() {
Qt.quit();
console.log("Daisy, Daisy, give me your answer do. I'm half crazy all for the love of you. It won't be a stylish marriage, I can't afford a carriage. But you'll look sweet upon the seat of a bicycle built for two.");
}
function parseServerResponse(message, ev) {
var res = JSON.parse(message);
switch(res.type) {
case "connected":
ev.gameConnected();
break;
case "start":
ev.setupGame(res);
break;
case "events":
ev.gameEvent(message)
break;
case "end":
ev.exitGame();
break;
case "error":
console.log(message)
break;
default: console.log("unkown resp:"); console.log(message);
}
}