aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/connection.js
blob: 3911d3f2e65088bf66af255884fb8534308b6fcb (plain)
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
function _Connection(root) {"use strict";
        if (!root) {
            root = location.origin + "/api/v1";
        }
        this.root = root;
    }
_Connection.prototype.init=function() {"use strict";
    this.openWebSocketConnection();
};
_Connection.prototype.openWebSocketConnection=function() {"use strict";
    this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws");
    var ws = this.ws;

    ws.onopen = this.onopen.bind(this);
    ws.onmessage = this.onmessage.bind(this);
    ws.onerror = this.onerror.bind(this);
    ws.onclose = this.onclose.bind(this);
};
_Connection.prototype.onopen=function(open) {"use strict";
    console.log("onopen", this, arguments);
};
_Connection.prototype.onmessage=function(message) {"use strict";
    //AppDispatcher.dispatchServerAction(...);
    console.log("onmessage", this, arguments);
};
_Connection.prototype.onerror=function(error) {"use strict";
    console.log("onerror", this, arguments);
};
_Connection.prototype.onclose=function(close) {"use strict";
    console.log("onclose", this, arguments);
};

var Connection = new _Connection();