CIRCServer.onSendData Member

Syntax

object.onSendData(e);

Arguments

ArgumentSummary
e

Returns

Remarks

See Also

Source Code

function serv_onsenddata (e)
{
if (!this.isConnected || (this.parent.state == NET_CANCELLING))
{
dd ("Can't send to disconnected socket");
this.flushSendQueue();
return false;
}
var d = new Date();
this.sendsThisRound = 0;
// Wheee, some sanity checking! (there's been at least one case of lastSend
// ending up in the *future* at this point, which kinda busts things)
if (this.lastSend > d)
this.lastSend = 0;
if (((d - this.lastSend) >= this.MS_BETWEEN_SENDS) &&
this.sendQueue.length > 0)
{
var s = this.sendQueue.pop();
if (s)
{
try
{
this.connection.sendData(s);
}
catch(ex)
{
dd("Exception in queued send: " + ex);
this.flushSendQueue();
var ev = new CEvent("server", "disconnect",
this, "onDisconnect");
ev.server = this;
ev.reason = "error";
ev.exception = ex;
ev.disconnectStatus = NS_ERROR_ABORT;
this.parent.eventPump.addEvent(ev);
return false;
}
this.lastSend = d;
}
}
else
{
this.parent.eventPump.addEvent(new CEvent("event-pump", "yield",
null, ""));
}
if (this.sendQueue.length > 0)
this.parent.eventPump.addEvent(new CEvent("server", "senddata",
this, "onSendData"));
return true;
}