Packagevegas.net
Classpublic dynamic class NetServerConnection
InheritanceNetServerConnection Inheritance CoreEventDispatcher Inheritance Object
Implements Action, Cloneable

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 system.events.ActionEvent ;
     
     import vegas.events.NetServerEvent ;
     import vegas.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("debug " + 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") ; // The RTMP application server
     



Public Properties
 PropertyDefined By
 Inheritedchannel : String
[read-only] 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
  connection : NetConnection
[read-only] Indicates the internal NetConnection reference of this object.
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
  finishIt : Signaler
This signal emit when the notifyFinished method is invoked.
NetServerConnection
  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
The ObjectEncoding class allows classes that serialize objects (such as FileStream, NetStream, NetConnection, SharedObject, and ByteArray) to work with prior versions of ActionScript.
NetServerConnection
  phase : String
[read-only] The current phase of the action.
NetServerConnection
  protocol : String
[read-only] Indicates the protocol used to establish the connection.
NetServerConnection
  proxyType : String
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
  running : Boolean
[read-only] Indicates true if the process is in progress.
NetServerConnection
  startIt : Signaler
This signal emit when the notifyStarted method is invoked.
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] Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.
NetServerConnection
Public Methods
 MethodDefined By
  
NetServerConnection(global:Boolean = false, channel: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 system.events.EventDispatcher reference.
CoreEventDispatcher
  
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
isGlobal():Boolean
Indicates if the dispatcher use a global event flow.
CoreEventDispatcher
 Inherited
isLocked():Boolean
Returns true if the object is locked.
CoreEventDispatcher
 Inherited
lock():void
Locks the object.
CoreEventDispatcher
  
Invoked when the connection is finished.
NetServerConnection
  
Invoked when the connection is started.
NetServerConnection
 Inherited
registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = 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 system.events.EventDispatcher to dispatch this events, if the flag value is false the instance use a local EventDispatcher.
CoreEventDispatcher
  
Use limit timeout interval.
NetServerConnection
  
sharedEvent(event:* = null, context:* = null):void
Use this method to dispatch in FMS application an event.
NetServerConnection
 Inherited
unlock():void
Unlocks the display.
CoreEventDispatcher
 Inherited
unregisterEventListener(type:String, listener:*, useCapture:Boolean = 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
 Inherited
Creates and returns the internal EventDispatcher reference (this method is invoked in the constructor).
CoreEventDispatcher
  
notifyNetServerEvent(type:String, status:NetServerStatus = null, info:* = null):void
Invoked when the connection is closed.
NetServerConnection
  
Invoked when the connection is timeout.
NetServerConnection
  
setRunning(b:Boolean):void
Changes the running property value.
NetServerConnection
Public Constants
 ConstantDefined By
  DEFAULT_DELAY : uint = 8000
[static] The default internal timeout delay value in milliseconds.
NetServerConnection
Property Detail
clientproperty
client:Object

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
connectionproperty 
connection:NetConnection  [read-only]

Indicates the internal NetConnection reference of this object.


Implementation
    public function get connection():NetConnection
defaultObjectEncodingproperty 
defaultObjectEncoding:uint

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 static 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
finishItproperty 
finishIt:Signaler

This signal emit when the notifyFinished method is invoked.


Implementation
    public function get finishIt():Signaler
    public function set finishIt(value:Signaler):void
maxPeerConnectionsproperty 
maxPeerConnections:uint

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

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
phaseproperty 
phase:String  [read-only]

The current phase of the action.


Implementation
    public function get phase():String

See also

protocolproperty 
protocol:String  [read-only]

Indicates the protocol used to establish the connection.


Implementation
    public function get protocol():String
proxyTypeproperty 
proxyType:String

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
runningproperty 
running:Boolean  [read-only]

Indicates true if the process is in progress.


Implementation
    public function get running():Boolean
startItproperty 
startIt:Signaler

This signal emit when the notifyStarted method is invoked.


Implementation
    public function get startIt():Signaler
    public function set startIt(value:Signaler):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

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. This 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]

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(global:Boolean = false, channel:String = null)

Creates a new NetServerConnection instance.

Parameters
global:Boolean (default = false) — the flag to use a global event flow or a local event flow.
 
channel:String (default = null) — the name of the global event flow if the global 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
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 
public 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 
public 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
setRunning()method 
protected function setRunning(b:Boolean):void

Changes the running property value.

Parameters

b:Boolean

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)

Constant Detail
DEFAULT_DELAYConstant
public static const DEFAULT_DELAY:uint = 8000

The default internal timeout delay value in milliseconds.