Bug 753807 - Land in comm-central Instantbird's changes to chat/ - Bio 1409 - Handle (dis)connects better in IRC, r=fqueze.
This commit is contained in:
Родитель
edf3e36107
Коммит
fb5ebce47e
|
@ -55,7 +55,6 @@
|
|||
* High-level methods:
|
||||
* .connect(<host>, <port>[, ("starttls" | "ssl" | "udp") [, <proxy>]])
|
||||
* .disconnect()
|
||||
* .reconnect()
|
||||
* .listen(port)
|
||||
* .send(String data)
|
||||
* .isAlive()
|
||||
|
@ -176,15 +175,6 @@ const Socket = {
|
|||
}
|
||||
},
|
||||
|
||||
// Reconnect to the current settings stored in the socket.
|
||||
reconnect: function() {
|
||||
// If there's nothing to reconnect to or we're connected, do nothing
|
||||
if (!this.isAlive() && this.host && this.port) {
|
||||
this.disconnect();
|
||||
this.connect(this.host, this.port, this.security, this.proxy);
|
||||
}
|
||||
},
|
||||
|
||||
// Disconnect all open streams.
|
||||
disconnect: function() {
|
||||
this.log("Disconnect");
|
||||
|
|
|
@ -817,6 +817,7 @@ ircAccount.prototype = {
|
|||
_quitTimer: null,
|
||||
// RFC 2812 Section 3.1.7.
|
||||
quit: function(aMessage) {
|
||||
this.reportDisconnecting(Ci.prplIAccount.NO_ERROR);
|
||||
this.sendMessage("QUIT",
|
||||
aMessage || this.getString("quitmsg") || undefined);
|
||||
},
|
||||
|
@ -827,6 +828,12 @@ ircAccount.prototype = {
|
|||
|
||||
this.reportDisconnecting(Ci.prplIAccount.NO_ERROR);
|
||||
|
||||
// If there's no socket, disconnect immediately to avoid waiting 2 seconds.
|
||||
if (!this._socket || !this._socket.isAlive()) {
|
||||
this.gotDisconnected();
|
||||
return;
|
||||
}
|
||||
|
||||
// Let the server know we're going to disconnect.
|
||||
this.quit();
|
||||
|
||||
|
@ -923,6 +930,11 @@ ircAccount.prototype = {
|
|||
// TODO This should escape any characters that can't be used in IRC (e.g.
|
||||
// \001, \r\n).
|
||||
|
||||
if (!this._socket || !this._socket.isAlive()) {
|
||||
this.gotDisconnected(Ci.prplIAccount.ERROR_NETWORK_ERROR,
|
||||
_("connection.error.lost"));
|
||||
}
|
||||
|
||||
let length = this.countBytes(aMessage) + 2;
|
||||
if (length > this.maxMessageLength) {
|
||||
// Log if the message is too long, but try to send it anyway.
|
||||
|
|
|
@ -211,9 +211,21 @@ var ircBase = {
|
|||
"ERROR": function(aMessage) {
|
||||
// ERROR <error message>
|
||||
// Client connection has been terminated.
|
||||
clearTimeout(this._quitTimer);
|
||||
this.gotDisconnected(Ci.prplIAccount.NO_ERROR,
|
||||
aMessage.params[0]); // Notify account manager.
|
||||
if (!this.disconnecting) {
|
||||
// We received an ERROR message when we weren't expecting it, this is
|
||||
// probably the server giving us a ping timeout.
|
||||
ERROR("Received unexpected ERROR response:\n" + aMessage.params[0]);
|
||||
this.gotDisconnected(Ci.prplIAccount.ERROR_NETWORK_ERROR,
|
||||
_("connection.error.lost"));
|
||||
}
|
||||
else {
|
||||
// We received an ERROR message when expecting it (i.e. we've sent a
|
||||
// QUIT command).
|
||||
clearTimeout(this._quitTimer);
|
||||
delete this._quitTimer;
|
||||
// Notify account manager.
|
||||
this.gotDisconnected();
|
||||
}
|
||||
return true;
|
||||
},
|
||||
"INVITE": function(aMessage) {
|
||||
|
@ -297,7 +309,7 @@ var ircBase = {
|
|||
},
|
||||
"PING": function(aMessage) {
|
||||
// PING <server1 [ <server2> ]
|
||||
// Keep the connection alive
|
||||
// Keep the connection alive.
|
||||
this.sendMessage("PONG", aMessage.params[0]);
|
||||
return true;
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче