This NetConnectionChannel provides the basic NetConnection support for messaging. The AMFChannel and RTMPChannel both extend this class.

Constructor

@:value({ uri : null, id : null })new(?id:String, ?uri:String)

Creates a new NetConnectionChannel instance.

The underlying NetConnection's objectEncoding is set to ObjectEncoding.AMF3 by default. It can be changed manually by accessing the channel's netConnection property. The global NetConnection.defaultObjectEncoding setting is not honored by this channel.

Parameters:

id

The id of this Channel.

uri

The uri for this Channel.

Variables

@:flash.propertyread onlynetConnection:AMFNetConnection

Provides access to the associated NetConnection for this Channel.

Methods

AppendToGatewayUrl(value:String):Void

Special handler for legacy AMF packet level header "AppendToGatewayUrl". When we receive this header we assume the server detected that a session was created but it believed the client could not accept its session cookie, so we need to decorate the channel endpoint with the session id.

We do not modify the underlying endpoint property, however, as this session is transient and should not apply if the channel is disconnected and re-connected at some point in the future.

receive(msg:IMessage, rest:Rest<Dynamic>):Void

Called by the player when the server pushes a message. Dispatches a MessageEvent to any MessageAgents that are listening. Any ...rest args passed via RTMP are ignored.

Parameters:

msg

The message pushed from the server.

Inherited Variables

Defined by Channel

@:flash.propertyread onlyauthenticated:Bool

Indicates if this channel is authenticated.

@:flash.propertyread onlychannelSets:Array<ChannelSet>

Provides access to the ChannelSets connected to the Channel.

@:flash.propertyconnectTimeout: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.

@:flash.propertyread onlyconnected:Bool

Indicates whether this channel has established a connection to the remote destination.

@:flash.propertyread onlyendpoint:String

Provides access to the endpoint for this channel. This value is calculated based on the value of the uri property.

@:flash.propertyfailoverURIs: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.

@:flash.propertyid:String

Provides access to the id of this channel.

@:flash.propertyread 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".

@:flash.propertyread onlyreconnecting:Bool

Indicates whether this channel is in the process of reconnecting to an alternate endpoint.

@:flash.propertyread onlyrecordMessageSizes:Bool

Channel property determines the level of performance information injection - whether we inject message sizes or not.

@:flash.propertyread onlyrecordMessageTimes:Bool

Channel property determines the level of performance information injection - whether we inject timestamps or not.

@:flash.propertyrequestTimeout: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.

@:flash.propertyuri: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.

Inherited Methods

Defined by PollingChannel

disablePolling():Void

Disables polling based on the number of times enablePolling() and disablePolling() have been invoked. If the net result is to disable polling the channel stops polling.

Invoked automatically based upon subscribing or unsubscribing from a remote destination over a PollingChannel.

enablePolling():Void

Enables polling based on the number of times enablePolling() and disablePolling() have been invoked. If the net result is to enable polling the channel will poll the server on behalf of connected MessageAgents.

Invoked automatically based upon subscribing or unsubscribing from a remote destination over a PollingChannel.

poll():Void

Initiates a poll operation if there are consumers subscribed to this channel, and polling is enabled for this channel.

Note that this method will not start a new poll if one is currently in progress.

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. PollingChannel will wrap outbound messages in poll requests if a poll is not currently outstanding.

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.

Defined by Channel

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.

@:value({ charset : null, agent : null })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.