deactivated automatic client reconnection

This commit is contained in:
logsol 2012-07-28 01:08:27 +02:00
parent ebb400a289
commit 5d11540c55
3 changed files with 20 additions and 7 deletions

View file

@ -5,8 +5,8 @@ define([
function(Networker, SocketIO) { function(Networker, SocketIO) {
function Client(location) { function Client(location, options) {
this.socket = SocketIO.connect(location); this.socket = SocketIO.connect(location, options);
this.networker = new Networker(this.socket); this.networker = new Networker(this.socket);
} }

View file

@ -23,14 +23,15 @@ function(ProtocolHelper, GameController) {
this.socketLink.on('message', function(message) { this.socketLink.on('message', function(message) {
self.onMessage(message); self.onMessage(message);
}); });
*/
this.socketLink.on('disconnect', function() { this.socketLink.on('disconnect', function() {
self.onDisconnect(); self.onDisconnect();
}); });
*/
} }
Networker.prototype.onConnect = function() { Networker.prototype.onConnect = function() {
console.log('connected.')
this.join('dungeon'); this.join('dungeon');
} }
/* /*
@ -40,12 +41,13 @@ function(ProtocolHelper, GameController) {
self.processControlCommand(command, options); self.processControlCommand(command, options);
}); });
} }
*/
Networker.prototype.onDisconnect = function() { Networker.prototype.onDisconnect = function() {
if(this.gameController) this.gameController.destruct(); if(this.gameController) this.gameController.destruct();
this.gameController = null; this.gameController = null;
console.log('disconnected. game destroyed. no auto-reconnect');
} }
*/
Networker.prototype.join = function(channelName){ Networker.prototype.join = function(channelName){
this.sendCommand('join', channelName); this.sendCommand('join', channelName);
} }

View file

@ -6,6 +6,17 @@ var inspector = {};
requirejs(["Bootstrap/Client"], function(Client) { requirejs(["Bootstrap/Client"], function(Client) {
var client = new Client(location.href); var options = {
"reconnect": false,
"reconnection delay": 500,
"max reconnection attempts": 10,
"transports": [
"websocket",
"flashsocket"
],
};
var client = new Client(location.href, options);
inspector.client = client; inspector.client = client;
}); });