blob: 3f64ed3274f32b48c49df31882fe71203ca77aff (
plain) (
blame)
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
|
import bean from 'bean';
import r from 'hatter/renderer';
import * as util from 'hatter/util';
import * as common from 'hatter/common';
import * as vt from 'hatter/vt';
import 'static!static/index.html';
import 'style/main.scss';
function main() {
let conn = new WebSocket(wsAddress);
conn.onopen = () => {
let root = document.body.appendChild(document.createElement('div'));
let state = util.set('conn', conn, common.defaultState);
r.init(root, state, vt.main);
};
conn.onclose = () => {
alert("Disconnected from server");
};
conn.onerror = () => {
alert("Couldn't connect to server");
};
conn.onmessage = (evt) => {
try {
let msg = JSON.parse(evt.data);
common.processMsg(msg);
} catch(e) {
conn.close();
throw e;
}
};
}
bean.on(window, 'load', main);
|