CBSConnection.accept Member

Syntax

object.accept(transport, observer);

Arguments

ArgumentSummary
transport
observer

Returns

Remarks

See Also

Source Code

function bc_accept(transport, observer)
{
this._transport = transport;
this.host = this._transport.host.toLowerCase();
this.port = this._transport.port;
if (jsenv.HAS_STREAM_PROVIDER)
{
if (jsenv.HAS_NSPR_EVENTQ)
{ /* we've got an event queue, so start up an async write */
this._streamProvider = new StreamProvider (observer);
this._write_req =
this._transport.asyncWrite (this._streamProvider, this,
0, -1, 0);
}
else
{
/* no nspr event queues in this environment, we can't use async
* calls, so set up the streams. */
this._outputStream = this._transport.openOutputStream(0, -1, 0);
if (!this._outputStream)
throw "Error getting output stream.";
this._sOutputStream = toSOutputStream(this._outputStream,
this.binaryMode);
//this._scriptableInputStream =
this._inputStream = this._transport.openInputStream(0, -1, 0);
if (!this._inputStream)
throw "Error getting input stream.";
this._sInputStream = toSInputStream(this._inputStream,
this.binaryMode);
}
}
else
{
/* if we don't have an event queue, then all i/o must be blocking */
var openFlags;
if (jsenv.HAS_NSPR_EVENTQ)
openFlags = 0;
else
openFlags = Components.interfaces.nsITransport.OPEN_BLOCKING;
/* no limit on the output stream buffer */
this._outputStream =
this._transport.openOutputStream(openFlags, 4096, -1);
if (!this._outputStream)
throw "Error getting output stream.";
this._sOutputStream = toSOutputStream(this._outputStream,
this.binaryMode);
this._inputStream = this._transport.openInputStream(openFlags, 0, 0);
if (!this._inputStream)
throw "Error getting input stream.";
this._sInputStream = toSInputStream(this._inputStream,
this.binaryMode);
}
this.connectDate = new Date();
this.isConnected = true;
// Clean up listening socket.
this.close();
return this.isConnected;
}