CIRCNetwork.onDisconnect Member

Syntax

object.onDisconnect(e);

Arguments

ArgumentSummary
e

Returns

Remarks

See Also

Source Code

function my_netdisconnect (e)
{
var msg, msgNetwork;
var msgType = MT_ERROR;
var retrying = true;
if (typeof e.disconnectStatus != "undefined")
{
switch (e.disconnectStatus)
{
case 0:
msg = getMsg(MSG_CONNECTION_CLOSED,
[this.getURL(), e.server.getURL()]);
break;
case NS_ERROR_CONNECTION_REFUSED:
msg = getMsg(MSG_CONNECTION_REFUSED,
[this.getURL(), e.server.getURL()]);
break;
case NS_ERROR_NET_TIMEOUT:
msg = getMsg(MSG_CONNECTION_TIMEOUT,
[this.getURL(), e.server.getURL()]);
break;
case NS_ERROR_NET_RESET:
msg = getMsg(MSG_CONNECTION_RESET,
[this.getURL(), e.server.getURL()]);
break;
case NS_ERROR_UNKNOWN_HOST:
msg = getMsg(MSG_UNKNOWN_HOST,
[e.server.hostname, this.getURL(),
e.server.getURL()]);
break;
case NS_ERROR_UNKNOWN_PROXY_HOST:
msg = getMsg(MSG_UNKNOWN_PROXY_HOST,
[this.getURL(), e.server.getURL()]);
break;
case NS_ERROR_PROXY_CONNECTION_REFUSED:
msg = MSG_PROXY_CONNECTION_REFUSED;
break;
case NS_ERROR_ABORT:
if (client.iosvc.offline)
{
msg = getMsg(MSG_CONNECTION_ABORT_OFFLINE,
[this.getURL(), e.server.getURL()]);
}
else
{
msg = getMsg(MSG_CONNECTION_ABORT_UNKNOWN,
[this.getURL(), e.server.getURL(),
formatException(e.exception)]);
}
retrying = false;
break;
// Group all certificate errors together.
// The exception adding dialog will explain the reasons.
case SEC_ERROR_EXPIRED_CERTIFICATE:
case SEC_ERROR_UNKNOWN_ISSUER:
case SEC_ERROR_UNTRUSTED_ISSUER:
case SEC_ERROR_UNTRUSTED_CERT:
case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
case SEC_ERROR_CA_CERT_INVALID:
case SEC_ERROR_INADEQUATE_KEY_USAGE:
case SSL_ERROR_BAD_CERT_DOMAIN:
var cmd = "ssl-exception";
cmd += " " + e.server.hostname + " " + e.server.port;
cmd += " true";
msg = getMsg(MSG_INVALID_CERT, [this.getURL(), cmd]);
retrying = false;
break;
default:
msg = getMsg(MSG_CLOSE_STATUS,
[this.getURL(), e.server.getURL(),
e.disconnectStatus]);
break;
}
}
else
{
msg = getMsg(MSG_CONNECTION_CLOSED,
[this.getURL(), e.server.getURL()]);
}
// e.quitting signals the disconnect was intended: don't use "ERROR".
if (e.quitting)
{
msgType = "DISCONNECT";
msg = getMsg(MSG_CONNECTION_QUIT,
[this.getURL(), e.server.getURL(), this.unicodeName,
"reconnect"]);
msgNetwork = msg;
}
// We won't reconnect if the error was really bad, or if the user doesn't
// want us to do so.
else if (!retrying || !this.stayingPower)
{
msgNetwork = msg;
}
else
{
var delayStr = formatDateOffset(this.getReconnectDelayMs() / 1000);
if (this.MAX_CONNECT_ATTEMPTS == -1)
{
msgNetwork = getMsg(MSG_RECONNECTING_IN,
[msg, delayStr, this.unicodeName, "cancel"]);
}
else if (this.connectAttempt < this.MAX_CONNECT_ATTEMPTS)
{
var left = this.MAX_CONNECT_ATTEMPTS - this.connectAttempt;
if (left == 1)
{
msgNetwork = getMsg(MSG_RECONNECTING_IN_LEFT1,
[msg, delayStr, this.unicodeName,
"cancel"]);
}
else
{
msgNetwork = getMsg(MSG_RECONNECTING_IN_LEFT,
[msg, left, delayStr, this.unicodeName,
"cancel"]);
}
}
else
{
msgNetwork = getMsg(MSG_CONNECTION_EXHAUSTED, msg);
}
}
/* If we were connected ok, put an error on all tabs. If we were only
* /trying/ to connect, and failed, just put it on the network tab.
*/
client.munger.getRule(".inline-buttons").enabled = true;
if (this.state == NET_ONLINE)
{
for (var v in client.viewsArray)
{
var obj = client.viewsArray[v].source;
if (obj == this)
{
obj.displayHere(msgNetwork, msgType);
}
else if (obj != client)
{
var details = getObjectDetails(obj);
if ("server" in details && details.server == e.server)
obj.displayHere(msg, msgType);
}
}
}
else
{
this.busy = false;
updateProgress();
// Don't do anything if we're cancelling.
if (this.state != NET_CANCELLING)
{
this.displayHere(msgNetwork, msgType);
}
}
client.munger.getRule(".inline-buttons").enabled = false;
for (var c in this.primServ.channels)
{
var channel = this.primServ.channels[c];
channel._clearUserList();
}
dispatch("sync-header");
updateTitle();
updateProgress();
updateSecurityIcon();
client.ident.removeNetwork(this);
if ("userClose" in client && client.userClose &&
client.getConnectionCount() == 0)
window.close();
if (("reconnect" in this) && this.reconnect)
{
this.connect(this.requireSecurity);
delete this.reconnect;
}
}