Construct a new XHRTransport instance
the connection options
the transport constructor function
The connection URI
A flag indicating whether sending of poll requests has been aborted
The emitter used for emitting events
A flag indicating that the transport is currently sending requests
The connection options
A sequence number for ping requests
The last poll request
A sequence number for polling requests
The protocol version
The message queue
The session token that was received from the server at connection
The transport constructor function
Whether a failed request should be sent again.
A status of 0 is the browser reporting a transport-level failure - a request that was aborted, blocked or never completed - rather than a response the server sent. Any other status is an answer from the server and repeating the request will not change it.
the status of the failed request
the attempt number that just failed, counting from 1
the number of attempts this kind of request gets
Aborting any opening poll request.
this instance
Establish a polling connection with the server.
the connection request
a handshake deserialiser
This is the generic method to send data to the server
the headers to send to the server
the URI to connect to
Queue message to be sent to the message message-queue.
Delegate the actual request sending to #flush().
to be queued
Flush all pending messages from the message-queue and send upstream.
Remove a listener from a specified event.
Example:
// Bind a single listener to the 'foo' event and then deregister it
var listener = function() {};
stream.on('foo', listener);
stream.off('foo', listener);
Example:
// Bind a listener to the 'foo' event and deregister all listeners
var listener = function() {};
stream.on('foo', listener);
stream.off('foo');
the listener to remove. All listeners for the event are removed if this is not specified. This argument is ignored if the first argument is a CallbackMap.
this stream.
Register listeners against events.
A single listener may be bound to an event by passing the event name and listener function.
Multiple listeners may be bound by passing in a CallbackMap, mapping event names to listener functions.
Example:
// Bind a single listener to the 'foo' event
stream.on('foo', function(arg1, arg2) {
console.log("Called for 'foo' event", arg1, arg2);
});
Example:
// Bind multiple listeners
stream.on({
foo : function() { ... },
bar : function() { ... },
baz : function() { ... }
});
It is possible to bind multiple listeners to the same event. In this case, the listeners will be called in the order they were bound.
the event name or CallbackMap mapping event names to listeners
the listener to bind to the event, if passed as string. This argument is ignored if the first argument is a CallbackMap.
this stream.
Send a poll request to the server.
Report a request failure that closes the session.
The status and the attempt it failed on are the only evidence of why the transport gave up rather than retried, and neither survives anywhere else. An aborted request is an expected close, so it is not reported.
'Poll' or 'Send', naming the request that failed
the status of the failed request
the attempt number that just failed, counting from 1
the number of attempts that kind of request gets
Schedule the next attempt at a failed request.
the attempt number that just failed, counting from 1
sends the next attempt
Send drained messages to the server.
A retry repeats the original sequence number. The server orders these requests and closes the channel if a gap is not filled within its message-sequence-timeout, while a request it has already handled is dropped as a duplicate - so repeating the sequence is correct whether or not the failed attempt arrived.
the drained messages
the sequence number for this request
the attempt number for this request, counting from 1
Send a poll request to the server.
The server ignores a poll's sequence number, so a retry simply takes the next one.
the attempt number for this poll, counting from 1
Copyright © 2025 DiffusionData Ltd. All Rights Reserved.
The implementation of the Transport interface for XHR polling