Packageasgard.net
Classpublic class NetServerConnection
InheritanceNetServerConnection Inheritance CoreEventDispatcher Inheritance CoreObject
ImplementsCloneable, Runnable
SubclassesRemotingConnection

This class extends the NetConnection class and defined an implementation based on VEGAS to used Flash Remoting or Flash MediaServer (with AMF protocol).

Example :

   import andromeda.events.ActionEvent ;
   import asgard.events.NetServerEvent ;
   import asgard.net.NetServerConnection ;
   
   import flash.events.Event ;
   
   var status:Function = function( e:NetStatusEvent ):void
   {
       trace("status " + e ) ;
       var info:Object = e.info ;
       for (var prop:String in info)
       {
           trace(prop + " : " + info[prop]) ;
       }
       trace("----") ;
   }
   
   var accept:Function = function( e:NetServerEvent ):void
   {
       trace("accept " + e.info ) ;
       trace("----") ;
   }
   
   var reject:Function = function( e:NetServerEvent ):void
   {
       trace("reject " + e.info ) ;
       trace("----") ;
   }
   
   var debug:Function = function( e:Event ):void
   {
       trace(">>>> " + e) ;
   }
   
   var nc:NetServerConnection = new NetServerConnection() ;
   
   nc.addEventListener(ActionEvent.FINISH    , debug ) ;
   nc.addEventListener(ActionEvent.START     , debug ) ;
   nc.addEventListener(NetServerEvent.ACCEPT , accept ) ;
   nc.addEventListener(NetServerEvent.REJECT , reject ) ;
   nc.addEventListener(NetStatusEvent.NET_STATUS , status ) ;
   
   nc.objectEncoding = ObjectEncoding.AMF0 ;
   
   nc.connect("rtmp://localhost/yourapplication") ; // creates in your FMS server a little main.asc file
   



Public Properties
 PropertyDefined by
 Inheritedchannel : String
Indicates the channel of this dispatcher if this instance is global.
CoreEventDispatcher
  client : Object
The default object encoding (AMF version) for NetConnection objects created in the SWF file.
NetServerConnection
  connected : Boolean
[read-only] [read-only] Indicates whether Flash Player has connected to a server through a persistent RTMP connection (true) or not (false).
NetServerConnection
  connectedProxyType : String
[read-only] [read-only] Indicates whether Flash Player has connected to a server through a persistent RTMP connection (true) or not (false).
NetServerConnection
  defaultObjectEncoding : uint
[static] The default object encoding (AMF version) for NetConnection objects created in the SWF file.
NetServerConnection
  farID : String
[read-only] The identifier of the Flash Media Server instance to which this Flash Player or Adobe AIR instance is connected.
NetServerConnection
  farNonce : String
[read-only] A value chosen substantially by Flash Media Server, unique to this connection.
NetServerConnection
 InheritedisGlobal : Boolean
(read-only) Returns the value of the isGlobal flag of this model.
CoreEventDispatcher
  maxPeerConnections : uint
The total number of inbound and outbound peer connections that this instance of Flash Player or Adobe AIR allows.
NetServerConnection
  nearID : String
[read-only] The identifier of this Flash Player or Adobe AIR instance for this NetConnection instance.
NetServerConnection
  nearNonce : String
[read-only] A value chosen substantially by this Flash Player or Adobe AIR instance, unique to this connection.
NetServerConnection
  objectEncoding : uint
(read write) The ObjectEncoding class allows classes that serialize objects (such as FileStream, NetStream, NetConnection, SharedObject, and ByteArray) to work with prior versions of ActionScript.
NetServerConnection
  protocol : String
[read-only] The protocol used to establish the connection.
NetServerConnection
  proxyType : String
(read write) Determines whether native SSL is used for RTMPS instead of HTTPS, and whether the CONNECT method of tunneling is used to connect through a proxy server.
NetServerConnection
  unconnectedPeerStreams : Array
[read-only] An object that holds all of the peer subscriber NetStream objects that are not associated with publishing NetStream objects.
NetServerConnection
  uri : String
The URI of the application server that was passed to NetConnection.connect(), if connect was used to connect to a server.
NetServerConnection
  usingTLS : Boolean
[read-only] [read-only] Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.
NetServerConnection
Public Methods
 MethodDefined by
  
NetServerConnection(bGlobal:Boolean = false, sChannel:String = null)
Creates a new NetServerConnection instance.
NetServerConnection
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void
Allows the registration of event listeners on the event target.
CoreEventDispatcher
  
addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void
Adds a context header to the AMF packet structure.
NetServerConnection
  
call(command:String, responder:Responder, ... rest):Boolean
Invokes a command or method on the server running Flash Media Server, or on an application server, to which the application instance is connected.
NetServerConnection
  
clone():*
Returns the shallow copy of this object.
NetServerConnection
  
close(noEvent:Boolean = false):Boolean
Closes the connection that was opened locally or with the server and dispatches the netStatus event with a code property of NetConnection.Connect.Closed.
NetServerConnection
  
connect(command:String, ... arguments):void
Connect the client with this method.
NetServerConnection
 Inherited
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
CoreEventDispatcher
  
getDelay():uint
Returns timeout interval duration.
NetServerConnection
 Inherited
Returns the internal EventDispatcher reference.
CoreEventDispatcher
  
[static] Returns the singleton instance of class.
NetServerConnection
 Inherited
getIsGlobal():Boolean
Returns the value of the isGlobal flag of this model.
CoreEventDispatcher
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreObject
  
Returns the TimeoutPolicy value of this object.
NetServerConnection
 Inherited
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
CoreEventDispatcher
 Inherited
hashCode():uint
Returns a hashcode value for the object.
CoreObject
 Inherited
Creates and returns the internal EventDispatcher reference (this method is invoked in the constructor).
CoreEventDispatcher
 Inherited
isLocked():Boolean
Returns true if the object is locked.
CoreEventDispatcher
 Inherited
lock():void
Locks the object.
CoreEventDispatcher
 Inherited
registerEventListener(type:String, listener:Boolean, useCapture:int = false, priority:Boolean = 0, useWeakReference:* = false):void
Allows the registration of event listeners on the event target (Function or EventListener).
CoreEventDispatcher
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
CoreEventDispatcher
  
run(... arguments):void
Runs the process of this NetServerConnection.
NetServerConnection
  
setDelay(n:Number, useSeconds:Boolean):void
Set timeout interval duration.
NetServerConnection
 Inherited
Sets the internal EventDispatcher reference.
CoreEventDispatcher
 Inherited
setGlobal(flag:Boolean = false, channel:String = null):void
Sets if the instance use a global EventDispatcher to dispatch this events, if the flag value is false the instance use a local EventDispatcher.
CoreEventDispatcher
  
Use limit timeout interval.
NetServerConnection
 Inherited
setLogger(log:ILogger = null):void
Sets the internal ILogger reference of this ILogable object.
CoreObject
  
sharedEvent(event:* = null, context:* = null):void
Use this method to dispatch in FMS application an event.
NetServerConnection
  
toNetConnection():NetConnection
Returns the internal NetConnection reference of this object.
NetServerConnection
 Inherited
toSource(indent:int = 0):String
Returns the string representation the source code of the object.
CoreEventDispatcher
 Inherited
toString():String
Returns the string representation of this instance.
CoreObject
 Inherited
unlock():void
Unlocks the display.
CoreEventDispatcher
 Inherited
unregisterEventListener(type:String, listener:Boolean, useCapture:* = false):void
Removes a listener (Function or EventListener object) from the EventDispatcher object.
CoreEventDispatcher
 Inherited
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
CoreEventDispatcher
Protected Methods
 MethodDefined by
  
Invoked when the connection is finished.
NetServerConnection
  
notifyNetServerEvent(type:String, status:NetServerStatus = null, info:* = null):void
Invoked when the connection is closed.
NetServerConnection
  
Invoked when the connection is started.
NetServerConnection
  
Invoked when the connection is timeout.
NetServerConnection
Public Constants
 ConstantDefined by
  DEFAULT_DELAY : uint = 8000
[static] The default internal timeout delay value in milliseconds.
NetServerConnection
Property detail
clientproperty
client:Object  [read-write]

The default object encoding (AMF version) for NetConnection objects created in the SWF file. When an object is written to or read from binary data, the defaultObjectEncoding property indicates which Action Message Format version should be used: the ActionScript 3.0 format or the ActionScript 1.0 and ActionScript 2.0 format.

Implementation
    public function get client():Object
    public function set client(value:Object):void
connectedproperty 
connected:Boolean  [read-only]

[read-only] Indicates whether Flash Player has connected to a server through a persistent RTMP connection (true) or not (false). When connected through HTTP, this property is always false. It is always true for AMF connections to application servers.

Implementation
    public function get connected():Boolean
connectedProxyTypeproperty 
connectedProxyType:String  [read-only]

[read-only] Indicates whether Flash Player has connected to a server through a persistent RTMP connection (true) or not (false). When connected through HTTP, this property is always false. It is always true for AMF connections to application servers.

Implementation
    public function get connectedProxyType():String
defaultObjectEncodingproperty 
defaultObjectEncoding:uint  [read-write]

The default object encoding (AMF version) for NetConnection objects created in the SWF file. When an object is written to or read from binary data, the defaultObjectEncoding property indicates which Action Message Format version should be used: the ActionScript 3.0 format or the ActionScript 1.0 and ActionScript 2.0 format.

Implementation
    public static function get defaultObjectEncoding():uint
    public function set defaultObjectEncoding(value:uint):void
farIDproperty 
farID:String  [read-only]

The identifier of the Flash Media Server instance to which this Flash Player or Adobe AIR instance is connected.

Implementation
    public function get farID():String
farNonceproperty 
farNonce:String  [read-only]

A value chosen substantially by Flash Media Server, unique to this connection.

Implementation
    public function get farNonce():String
maxPeerConnectionsproperty 
maxPeerConnections:uint  [read-write]

The total number of inbound and outbound peer connections that this instance of Flash Player or Adobe AIR allows.

Implementation
    public function get maxPeerConnections():uint
    public function set maxPeerConnections(value:uint):void
nearIDproperty 
nearID:String  [read-only]

The identifier of this Flash Player or Adobe AIR instance for this NetConnection instance.

Implementation
    public function get nearID():String
nearNonceproperty 
nearNonce:String  [read-only]

A value chosen substantially by this Flash Player or Adobe AIR instance, unique to this connection.

Implementation
    public function get nearNonce():String
objectEncodingproperty 
objectEncoding:uint  [read-write]

(read write) The ObjectEncoding class allows classes that serialize objects (such as FileStream, NetStream, NetConnection, SharedObject, and ByteArray) to work with prior versions of ActionScript.

Implementation
    public function get objectEncoding():uint
    public function set objectEncoding(value:uint):void
protocolproperty 
protocol:String  [read-only]

The protocol used to establish the connection.

Implementation
    public function get protocol():String
proxyTypeproperty 
proxyType:String  [read-write]

(read write) Determines whether native SSL is used for RTMPS instead of HTTPS, and whether the CONNECT method of tunneling is used to connect through a proxy server. Acceptable values are "none", "HTTP", "CONNECT", and "best". This property is used in Flex applications and Flash Media Server 2 applications.

Implementation
    public function get proxyType():String
    public function set proxyType(value:String):void
unconnectedPeerStreamsproperty 
unconnectedPeerStreams:Array  [read-only]

An object that holds all of the peer subscriber NetStream objects that are not associated with publishing NetStream objects.

Implementation
    public function get unconnectedPeerStreams():Array
uriproperty 
uri:String  [read-write]

The URI of the application server that was passed to NetConnection.connect(), if connect was used to connect to a server. If NetConnection.connect() hasn't yet been called or if no URI was passed, this property is undefined. In The VEGAS implementation the uri property is a read-write property and we can use this property in to launch the connect process with the run method.

Implementation
    public function get uri():String
    public function set uri(value:String):void

See also

Runnable
usingTLSproperty 
usingTLS:Boolean  [read-only]

[read-only] Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS. This property is valid only when a NetConnection object is connected.

Implementation
    public function get usingTLS():Boolean
Constructor detail
NetServerConnection()constructor
public function NetServerConnection(bGlobal:Boolean = false, sChannel:String = null)

Creates a new NetServerConnection instance.

Parameters
bGlobal:Boolean (default = false) — the flag to use a global event flow or a local event flow.
 
sChannel:String (default = null) — the name of the global event flow if the bGlobal argument is true.
Method detail
addHeader()method
public function addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void

Adds a context header to the AMF packet structure. This header is sent with every future AMF packet.

Parameters
operation:String — A string; identifies the header and the ActionScript object data associated with it.
 
mustUnderstand:Boolean (default = false) — A Boolean value; true indicates that the server must understand and process this header before it handles any of the following headers or messages.
 
param:Object (default = null) — Any ActionScript object.
call()method 
public function call(command:String, responder:Responder, ... rest):Boolean

Invokes a command or method on the server running Flash Media Server, or on an application server, to which the application instance is connected. You must create a server-side function to pass to this method.

Parameters
command:String — A method specified in the form [objectPath/]method.
 
responder:Responder — An optional object that is used to handle return values from the server.
 
... rest — arguments Optional arguments that can be of any ActionScript type, including a reference to another ActionScript object. These arguments are passed to the method specified in the command parameter when the method is executed on the remote application server.

Returns
Boolean — For RTMP connections, returns a Boolean value of true if a call to methodName is sent to the client ; otherwise, false. For application server connections, it always returns true.
clone()method 
public function clone():*

Returns the shallow copy of this object.

Returns
* — the shallow copy of this object.
close()method 
public function close(noEvent:Boolean = false):Boolean

Closes the connection that was opened locally or with the server and dispatches the netStatus event with a code property of NetConnection.Connect.Closed.

Parameters
noEvent:Boolean (default = false)

Returns
Boolean — A boolean to indicates if the connection is closed.
connect()method 
public function connect(command:String, ... arguments):void

Connect the client with this method.

Parameters
command:String
 
... arguments
getDelay()method 
public function getDelay():uint

Returns timeout interval duration.

Returns
uint
getInstance()method 
public static function getInstance():NetServerConnection

Returns the singleton instance of class.

Returns
NetServerConnection — singleton instance of class.
getTimeoutPolicy()method 
public function getTimeoutPolicy():TimeoutPolicy

Returns the TimeoutPolicy value of this object.

Returns
TimeoutPolicy — the TimeoutPolicy value of this object.

See also

TimeoutPolicy
notifyFinished()method 
protected function notifyFinished():void

Invoked when the connection is finished.

notifyNetServerEvent()method 
protected function notifyNetServerEvent(type:String, status:NetServerStatus = null, info:* = null):void

Invoked when the connection is closed.

Parameters
type:String
 
status:NetServerStatus (default = null)
 
info:* (default = null)
notifyStarted()method 
protected function notifyStarted():void

Invoked when the connection is started.

notifyTimeOut()method 
protected function notifyTimeOut():void

Invoked when the connection is timeout.

run()method 
public function run(... arguments):void

Runs the process of this NetServerConnection.

Parameters
... arguments
setDelay()method 
public function setDelay(n:Number, useSeconds:Boolean):void

Set timeout interval duration.

Parameters
n:Number
 
useSeconds:Boolean
setLimitPolicy()method 
public function setLimitPolicy(policy:TimeoutPolicy):void

Use limit timeout interval.

Parameters
policy:TimeoutPolicy

See also

TimeoutPolicy
sharedEvent()method 
public function sharedEvent(event:* = null, context:* = null):void

Use this method to dispatch in FMS application an event.

Parameters
event:* (default = null)
 
context:* (default = null)
toNetConnection()method 
public function toNetConnection():NetConnection

Returns the internal NetConnection reference of this object.

Returns
NetConnection — the internal NetConnection reference of this object.
Constant detail
DEFAULT_DELAYconstant
public static const DEFAULT_DELAY:uint = 8000

The default internal timeout delay value in milliseconds.