Packagenet.user1.reactor
Classpublic class HTTPConnection
InheritanceHTTPConnection Inheritance Connection Inheritance flash.events.EventDispatcher
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

Reactor.connect()
ConnectionManager.connect()
XMLSocketConnection
ConnectionManager.addConnection()
SecureHTTPConnection


Public Methods
 MethodDefined By
  
HTTPConnection(host:String, port:int = 80, type:String = null)
HTTPConnection
  
connect():void
[override] For documentation, see IConnection's connect() method.
HTTPConnection
 Inherited
disconnect():void
For documentation, see IConnection's disconnect() method.
Connection
  
dispose():void
[override] Permanently disables this object.
HTTPConnection
 Inherited
getHost():String
For documentation, see IConnection's getHost() method.
Connection
 Inherited
getPort():int
For documentation, see IConnection's getPort() method.
Connection
 Inherited
Returns an integer indicating the number of times this Connection object has successfully achieved a ready state.
Connection
 Inherited
For documentation, see IConnection's getRequestedHost() method.
Connection
  
Returns this connection's send-delay.
HTTPConnection
 Inherited
getType():String
For documentation, see IConnection's getType() method.
Connection
 Inherited
isReady():Boolean
For documentation, see IConnection's isReady() method.
Connection
 Inherited
isValid():Boolean
For documentation, see IConnection's isValid() method.
Connection
  
send(data:*):void
[override] For documentation, see IConnection's send() method.
HTTPConnection
 Inherited
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
Events
 Event Summary Defined By
 Inherited Dispatched when a connection attempt by an IConnection object begins.Connection
 Inherited Dispatched when an IConnection object initiates the "handshake" phase of a Union Server connection.Connection
 Inherited Dispatched when an IConnection object's connection to the server is closed by the client.Connection
 Inherited Dispatched when a connection attempt by an IConnection object fails.Connection
 Inherited Dispatched when an IConnection object achieves a fully initialized connection to the server.Connection
 Inherited 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
 Inherited Dispatched whenever any data is sent to Union Server over an IConnection object.Connection
 Inherited Dispatched when an IConnection object's connection to the server is closed by the server.Connection
 Inherited Dispatched when Union Server informs the client that a session id used in a message from the client refers to an unknown session.Connection
 Inherited Dispatched when Union Server informs the client that its session has been terminated.Connection
Public Constants
 ConstantDefined By
  DEFAULT_SEND_DELAY : int = 200
[static] The default send-delay used for new HTTPConnection objects.
HTTPConnection
Constructor Description
HTTPConnection()Constructor
public function HTTPConnection(host:String, port:int = 80, type:String = null)



Parameters
host:String
 
port:int (default = 80)
 
type:String (default = null)
Method Descriptions
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().

Returns
int

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.

Returns
String
Event Detail
RECEIVE_UPC Event
Event Object Type: ConnectionEvent
ConnectionEvent.type variable = net.user1.reactor.ConnectionEvent.RECEIVE_UPC

Dispatched when a UPC-formatted message is received by an IConnection object.

See also

Constant Descriptions
DEFAULT_SEND_DELAYConstant
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