class Channel
package feathers.messaging
extends EventDispatcher
extended by PollingChannel
The Channel class is the base message channel class that all channels in the messaging system must extend.
Channels are specific protocol-based conduits for messages sent between
MessageAgents and remote destinations.
Preconfigured channels are obtained within the framework using the
ServerConfig.getChannel()
method.
You can create a Channel directly using the new
operator and
add it to a ChannelSet directly.
Channels represent a physical connection to a remote endpoint. Channels are shared across destinations by default. This means that a client targetting different destinations may use the same Channel to communicate with these destinations.
Note: This class is for advanced use only. Use this class for creating custom channels like the existing RTMPChannel, AMFChannel, and HTTPChannel.
Constructor
new(?id:String, ?uri:String)
Constructs an instance of a generic Channel that connects to the specified endpoint URI.
Note: The Channel type should not be constructed directly. Instead create instances of protocol specific subclasses such as RTMPChannel or AMFChannel.
Parameters:
id | The id of this channel. |
---|---|
uri | The endpoint URI for this channel. |
Variables
connectTimeout:Int
Provides access to the connect timeout in seconds for the channel. A value of 0 or below indicates that a connect attempt will never be timed out on the client. For channels that are configured to failover, this value is the total time to wait for a connection to be established. It is not reset for each failover URI that the channel may attempt to connect to.
read onlyconnected:Bool
Indicates whether this channel has established a connection to the remote destination.
read onlyendpoint:String
Provides access to the endpoint for this channel.
This value is calculated based on the value of the uri
property.
failoverURIs:Array<String>
Provides access to the set of endpoint URIs that this channel can attempt to failover to if the endpoint is clustered.
This property is automatically populated when clustering is enabled. If you don't use clustering, you can set your own values.
read onlyprotocol:String
Provides access to the protocol that the channel uses. Note: Subclasses of Channel must override this method and return a string that represents their supported protocol. Examples of supported protocol strings are "rtmp", "http" or "https".
read onlyreconnecting:Bool
Indicates whether this channel is in the process of reconnecting to an alternate endpoint.
read onlyrecordMessageSizes:Bool
Channel property determines the level of performance information injection - whether we inject message sizes or not.
read onlyrecordMessageTimes:Bool
Channel property determines the level of performance information injection - whether we inject timestamps or not.
requestTimeout:Int
Provides access to the default request timeout in seconds for the channel. A value of 0 or below indicates that outbound requests will never be timed out on the client.
Request timeouts are most useful for RPC style messaging that requires a response from the remote destination.
uri:String
Provides access to the URI used to create the whole endpoint URI for this channel. The URI can be a partial path, in which case the full endpoint URI is computed as necessary.
Methods
applySettings(settings:Xml):Void
Subclasses should override this method to apply any settings that may be
necessary for an individual channel.
Make sure to call super.applySettings()
to apply common settings for the channel.
This method is used primarily in Channel subclasses.
Parameters:
settings | XML fragment of the services-config.xml file for this channel. |
---|
finalconnect(channelSet:ChannelSet):Void
Connects the ChannelSet to the Channel. If the Channel has not yet
connected to its endpoint, it attempts to do so.
Channel subclasses must override the internalConnect()
method, and call the connectSuccess()
method once the
underlying connection is established.
Parameters:
channelSet | The ChannelSet to connect to the Channel. |
---|
finaldisconnect(channelSet:ChannelSet):Void
Disconnects the ChannelSet from the Channel. If the Channel is connected to its endpoint and it has no more connected ChannelSets it will internally disconnect.
Channel subclasses need to override the
internalDisconnect()
method, and call the
disconnectSuccess()
method when the underlying connection
has been terminated.
Parameters:
channelSet | The ChannelSet to disconnect from the Channel. |
---|
logout(agent:MessageAgent):Void
Sends a CommandMessage to the server to logout if the Channel is connected. Current credentials are cleared.
Parameters:
agent | The MessageAgent to logout. |
---|
send(agent:MessageAgent, message:IMessage):Void
Sends the specified message to its target destination.
Subclasses must override the internalSend()
method to
perform the actual send.
Parameters:
agent | The MessageAgent that is sending the message. |
---|---|
message | The Message to send. |
Throws:
mx.messaging.errors.InvalidDestinationError | If neither the MessageAgent nor the message specify a destination. |
---|
setCredentials(credentials:String, ?agent:MessageAgent, ?charset:String):Void
Sets the credentials to the specified value. If the credentials are non-null and the Channel is connected, this method also sends a CommandMessage to the server to login using the credentials.
Parameters:
credentials | The credentials string. |
---|---|
agent | The MessageAgent to login, that will handle the login result. |
charset | The character set encoding used while encoding the credentials. The default is null, which implies the legacy charset of ISO-Latin-1. |
Throws:
flash.errors.IllegalOperationError | in two situations; if credentials have already been set and an authentication is in progress with the remote detination, or if authenticated and the credentials specified don't match the currently authenticated credentials. |
---|