Commit 309b626e authored by mercury233's avatar mercury233

catch stdout undefined

parent ad1f15a5
......@@ -242,23 +242,26 @@ class Room
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'), (if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'), @hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit]
@process = spawn './ygopro', param, cwd: 'ygocore'
@process.on 'exit', (code)=>
@disconnector = 'server' unless @disconnector
this.delete()
return
@process.stdout.setEncoding('utf8')
@process.stdout.once 'data', (data)=>
@established = true
@port = parseInt data
_.each @players, (player)=>
player.server.connect @port, '127.0.0.1',=>
player.server.write buffer for buffer in player.pre_establish_buffers
player.established = true
player.pre_establish_buffers = null
try
@process = spawn './ygopro', param, cwd: 'ygocore'
@process.on 'exit', (code)=>
@disconnector = 'server' unless @disconnector
this.delete()
return
@process.stdout.setEncoding('utf8')
@process.stdout.once 'data', (data)=>
@established = true
@port = parseInt data
_.each @players, (player)=>
player.server.connect @port, '127.0.0.1',=>
player.server.write buffer for buffer in player.pre_establish_buffers
player.established = true
player.pre_establish_buffers = null
return
return
return
return
catch
@error = "建立房间失败,请重试"
delete: ->
#积分
return if @deleted
......
......@@ -291,36 +291,40 @@
}
}
param = [0, this.hostinfo.lflist, this.hostinfo.rule, this.hostinfo.mode, (this.hostinfo.enable_priority ? 'T' : 'F'), (this.hostinfo.no_check_deck ? 'T' : 'F'), (this.hostinfo.no_shuffle_deck ? 'T' : 'F'), this.hostinfo.start_lp, this.hostinfo.start_hand, this.hostinfo.draw_count, this.hostinfo.time_limit];
this.process = spawn('./ygopro', param, {
cwd: 'ygocore'
});
this.process.on('exit', (function(_this) {
return function(code) {
if (!_this.disconnector) {
_this.disconnector = 'server';
}
_this["delete"]();
};
})(this));
this.process.stdout.setEncoding('utf8');
this.process.stdout.once('data', (function(_this) {
return function(data) {
_this.established = true;
_this.port = parseInt(data);
_.each(_this.players, function(player) {
player.server.connect(_this.port, '127.0.0.1', function() {
var buffer, i, len, ref;
ref = player.pre_establish_buffers;
for (i = 0, len = ref.length; i < len; i++) {
buffer = ref[i];
player.server.write(buffer);
}
player.established = true;
player.pre_establish_buffers = null;
try {
this.process = spawn('./ygopro', param, {
cwd: 'ygocore'
});
this.process.on('exit', (function(_this) {
return function(code) {
if (!_this.disconnector) {
_this.disconnector = 'server';
}
_this["delete"]();
};
})(this));
this.process.stdout.setEncoding('utf8');
this.process.stdout.once('data', (function(_this) {
return function(data) {
_this.established = true;
_this.port = parseInt(data);
_.each(_this.players, function(player) {
player.server.connect(_this.port, '127.0.0.1', function() {
var buffer, i, len, ref;
ref = player.pre_establish_buffers;
for (i = 0, len = ref.length; i < len; i++) {
buffer = ref[i];
player.server.write(buffer);
}
player.established = true;
player.pre_establish_buffers = null;
});
});
});
};
})(this));
};
})(this));
} catch (_error) {
this.error = "建立房间失败,请重试";
}
}
Room.prototype["delete"] = function() {
......
......@@ -284,6 +284,13 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
code: 2
}
client.end()
else if client.room.error
ygopro.stoc_send_chat(client,client.room.error)
ygopro.stoc_send client, 'ERROR_MSG',{
msg: 1
code: 2
}
client.end()
else if client.room.started
if settings.modules.post_start_watching
client.is_post_watcher = true
......
......@@ -292,6 +292,13 @@
code: 2
});
client.end();
} else if (client.room.error) {
ygopro.stoc_send_chat(client, client.room.error);
ygopro.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 2
});
client.end();
} else if (client.room.started) {
if (settings.modules.post_start_watching) {
client.is_post_watcher = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment