2014-09-16 21:40:25 +00:00
|
|
|
function _Connection(url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
_Connection.prototype.init=function() {
|
2014-09-16 09:06:30 +00:00
|
|
|
this.openWebSocketConnection();
|
|
|
|
};
|
2014-09-16 21:40:25 +00:00
|
|
|
_Connection.prototype.openWebSocketConnection=function() {
|
|
|
|
this.ws = new WebSocket(this.url.replace("http", "ws"));
|
2014-09-16 09:06:30 +00:00
|
|
|
var ws = this.ws;
|
2014-09-15 16:08:26 +00:00
|
|
|
|
2014-09-16 09:06:30 +00:00
|
|
|
ws.onopen = this.onopen.bind(this);
|
|
|
|
ws.onmessage = this.onmessage.bind(this);
|
|
|
|
ws.onerror = this.onerror.bind(this);
|
|
|
|
ws.onclose = this.onclose.bind(this);
|
|
|
|
};
|
2014-09-16 21:40:25 +00:00
|
|
|
_Connection.prototype.onopen=function(open) {
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onopen", this, arguments);
|
|
|
|
};
|
2014-09-16 21:40:25 +00:00
|
|
|
_Connection.prototype.onmessage=function(message) {
|
2014-09-16 09:06:30 +00:00
|
|
|
//AppDispatcher.dispatchServerAction(...);
|
|
|
|
console.log("onmessage", this, arguments);
|
|
|
|
};
|
2014-09-16 21:40:25 +00:00
|
|
|
_Connection.prototype.onerror=function(error) {
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onerror", this, arguments);
|
|
|
|
};
|
2014-09-16 21:40:25 +00:00
|
|
|
_Connection.prototype.onclose=function(close) {
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onclose", this, arguments);
|
|
|
|
};
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-16 21:40:25 +00:00
|
|
|
var Connection = new _Connection(location.origin + "/updates");
|