Package | net.user1.reactor |
Class | public class HTTPConnection |
Inheritance | HTTPConnection ![]() ![]() |
Subclasses | SecureHTTPConnection |
Since : | Reactor 1.0.0 |
The HTTPConnection class is used by Reactor to communicate with Union Server over HTTP. Normally, developers need not use the HTTPConnection class directly, and should instead make connections via the Reactor class's connect() method. However, the HTTPConnection class is required for fine-grained connection configuration, such as defining failover connections for multiple Union servers running at different host addresses (see the example in the ConnectionManager's main class entry).
By default, Reactor uses the XMLSocketConnection class, not the HTTPConnection class, to communicate with Union Server. The HTTPConnection class is primarily used for backup connections required when a main XMLSocketConnection connection is blocked by a firewall. However, on a very heavily loaded server with limited persistent socket connections available, communicating with Union Server over HTTP--which uses short-lived socket connections--can improve performance at the expense of realtime responsiveness. To reduce server load when communicating over HTTP, use HTTPConnection's setSendDelay() method to decrease the frequency of Reactor's requests for updates from Union Server. Developers that wish to use HTTP connections as the primary form of communication with Union Server must do so by manually configuring connections via the ConnectionManager class's addConnection() method.
See also
Method | Defined By | ||
---|---|---|---|
HTTPConnection(host:String, port:int = 80, type:String = null) | HTTPConnection | ||
connect():void [override]
For documentation, see IConnection's connect() method. | HTTPConnection | ||
![]() | disconnect():void
For documentation, see IConnection's disconnect() method. | Connection | |
dispose():void [override]
Permanently disables this object. | HTTPConnection | ||
![]() | getHost():String
For documentation, see IConnection's getHost() method. | Connection | |
![]() | getPort():int
For documentation, see IConnection's getPort() method. | Connection | |
![]() | getReadyCount():int
Returns an integer indicating the number of times this
Connection object has successfully achieved a ready state. | Connection | |
![]() | getRequestedHost():String
For documentation, see IConnection's getRequestedHost() method. | Connection | |
getSendDelay():int
Returns this connection's send-delay. | HTTPConnection | ||
![]() | getType():String
For documentation, see IConnection's getType() method. | Connection | |
![]() | isReady():Boolean
For documentation, see IConnection's isReady() method. | Connection | |
![]() | isValid():Boolean
For documentation, see IConnection's isValid() method. | Connection | |
send(data:*):void [override]
For documentation, see IConnection's send() method. | HTTPConnection | ||
![]() | setReactor(reactor:Reactor):void | Connection | |
setRetryDelay(milliseconds:int):void | HTTPConnection | ||
setSendDelay(milliseconds:int):void
Increases or decreases the connection's batch-message send rate, or
disables batch-sending entirely. | HTTPConnection | ||
setServer(host:String, port:int):void [override]
For documentation, see IConnection's setServer() method. | HTTPConnection | ||
toString():String [override]
Provides a string representation of this object. | HTTPConnection |
Event | Summary | Defined By | ||
---|---|---|---|---|
![]() | Dispatched when a connection attempt by an IConnection object begins. | Connection | ||
![]() | Dispatched when an IConnection object initiates the "handshake" phase of a Union Server connection. | Connection | ||
![]() | Dispatched when an IConnection object's connection to the server is closed by the client. | Connection | ||
![]() | Dispatched when a connection attempt by an IConnection object fails. | Connection | ||
![]() | Dispatched when an IConnection object achieves a fully initialized connection to the server. | Connection | ||
![]() | Dispatched whenever any data is received from Union Server by an IConnection object. | Connection | ||
Dispatched when a UPC-formatted message is received by an IConnection object. | HTTPConnection | |||
![]() | Dispatched whenever any data is sent to Union Server over an IConnection object. | Connection | ||
![]() | Dispatched when an IConnection object's connection to the server is closed by the server. | Connection | ||
![]() | Dispatched when Union Server informs the client that a session id used in a message from the client refers to an unknown session. | Connection | ||
![]() | Dispatched when Union Server informs the client that its session has been terminated. | Connection |
Constant | Defined By | ||
---|---|---|---|
DEFAULT_SEND_DELAY : int = 200 [static]
The default send-delay used for new HTTPConnection objects. | HTTPConnection |
HTTPConnection | () | Constructor |
public function HTTPConnection(host:String, port:int = 80, type:String = null)
host:String | |
port:int (default = 80 )
| |
type:String (default = null )
|
connect | () | method |
override public function connect():void
Since : | Reactor 1.0.0 |
For documentation, see IConnection's connect() method.
See also
dispose | () | method |
override public function dispose():void
Since : | Reactor 1.0.0 |
Permanently disables this object.
getSendDelay | () | method |
public function getSendDelay():int
Since : | Reactor 1.0.0 |
Returns this connection's send-delay. For details, see setSendDelay().
Returnsint |
See also
send | () | method |
override public function send(data:*):void
Since : | Reactor 1.0.0 |
For documentation, see IConnection's send() method.
Parameters
data:* |
See also
setRetryDelay | () | method |
public function setRetryDelay(milliseconds:int):void
Parameters
milliseconds:int |
setSendDelay | () | method |
public function setSendDelay(milliseconds:int):void
Since : | Reactor 1.0.0 |
Increases or decreases the connection's batch-message send rate, or disables batch-sending entirely. Reactor's HTTPConnection class uses a batch-message-sending system that reduces server load and client-side HTTP-request volume. In the default configuration, when an HTTPConnection sends messages via an HTTP request to Union Server, it starts a countdown known as the "send-countdown". The duration of the send-countdown is known as the "send-delay" (configurable via the setSendDelay() method). Until both the send-countdown expires and the response to the HTTP request is received, all outbound messages are queued. The queue is flushed when both the outbound HTTP request has completed and the send-countdown (if any) has expired.
Reactor's batch-message-sending system is part of Union's "binary request" HTTP communications model, which balances two principles: on one hand, for maximum responsiveness, Reactor always maintains an open HTTP request to Union Server (used to receive incoming messages from the server); on the other hand, for maximum efficiency, when an outgoing HTTP response is already pending, Reactor never sends another request, and when no outgoing HTTP response is pending, Reactor never sends messages to Union Server more frequently than the specified send-delay.
The default send-delay is defined by HTTPConnection.DEFAULT_SEND_DELAY, and is appropriate for the vast majority of applications. However, applications that require a reduced server load can opt for less frequent message delivery by increasing the send-delay. Conversely, applications that require maximum responsiveness can opt for more frequent message delivery by decreasing the send-delay, or by setting the send-delay to -1, which disables the message queue entirely. When the message queue is disabled, a new outgoing HTTP request will be opened any time there are messages to send and there is no outgoing request already pending. Warning: disabling the send-delay or setting it to a value lower than 200 milliseconds can result high server load. When setting send-delay to a custom value, be sure to test application behaviour thoroughly.
Parameters
milliseconds:int — The batched message send-delay, in milliseconds.
Defaults to HTTPConnection.DEFAULT_SEND_DELAY.
|
See also
setServer | () | method |
override public function setServer(host:String, port:int):void
Since : | Reactor 1.0.0 |
For documentation, see IConnection's setServer() method.
Parameters
host:String | |
port:int |
See also
toString | () | method |
override public function toString():String
Since : | Reactor 1.0.0 |
Provides a string representation of this object.
ReturnsString |
RECEIVE_UPC | Event |
ConnectionEvent
net.user1.reactor.ConnectionEvent.RECEIVE_UPC
Dispatched when a UPC-formatted message is received by an IConnection object.
See also
DEFAULT_SEND_DELAY | Constant |
public static const DEFAULT_SEND_DELAY:int = 200
Since : | Reactor 1.0.0 |
The default send-delay used for new HTTPConnection objects. For details, see setSendDelay().
See also