mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
deactivated automatic client reconnection
This commit is contained in:
parent
ebb400a289
commit
5d11540c55
3 changed files with 20 additions and 7 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
client.js
13
client.js
|
|
@ -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;
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue