| Package | asgard.net |
| Class | public class NetServerConnection |
| Inheritance | NetServerConnection CoreEventDispatcher CoreObject |
| Implements | Cloneable, Runnable |
| Subclasses | RemotingConnection |
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
| Property | Defined by | ||
|---|---|---|---|
![]() | channel : 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 | ||
![]() | isGlobal : 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 | ||
| Method | Defined by | ||
|---|---|---|---|
|
NetServerConnection(bGlobal:Boolean = false, sChannel:String = null)
Creates a new NetServerConnection instance.
| NetServerConnection | ||
![]() |
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 | ||
![]() |
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
| CoreEventDispatcher | |
|
getDelay():uint
Returns timeout interval duration.
| NetServerConnection | ||
![]() |
Returns the internal
EventDispatcher reference. | CoreEventDispatcher | |
|
[static]
Returns the singleton instance of class.
| NetServerConnection | ||
![]() |
getIsGlobal():Boolean
Returns the value of the isGlobal flag of this model.
| CoreEventDispatcher | |
![]() |
Returns the internal
ILogger reference of this ILogable object. | CoreObject | |
|
Returns the TimeoutPolicy value of this object.
| NetServerConnection | ||
![]() |
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
| CoreEventDispatcher | |
![]() |
hashCode():uint
Returns a hashcode value for the object.
| CoreObject | |
![]() |
Creates and returns the internal
EventDispatcher reference (this method is invoked in the constructor). | CoreEventDispatcher | |
![]() |
isLocked():Boolean
Returns
true if the object is locked. | CoreEventDispatcher | |
![]() |
lock():void
Locks the object.
| CoreEventDispatcher | |
![]() |
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 | |
![]() |
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 | ||
![]() |
setEventDispatcher(e:EventDispatcher):void
Sets the internal
EventDispatcher reference. | CoreEventDispatcher | |
![]() |
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 | |
|
setLimitPolicy(policy:TimeoutPolicy):void
Use limit timeout interval.
| NetServerConnection | ||
![]() |
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 | ||
![]() |
toSource(indent:int = 0):String
Returns the string representation the source code of the object.
| CoreEventDispatcher | |
![]() |
toString():String
Returns the string representation of this instance.
| CoreObject | |
![]() |
unlock():void
Unlocks the display.
| CoreEventDispatcher | |
![]() |
unregisterEventListener(type:String, listener:Boolean, useCapture:* = false):void
Removes a listener (Function or EventListener object) from the EventDispatcher object.
| CoreEventDispatcher | |
![]() |
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 | |
| Method | Defined by | ||
|---|---|---|---|
|
notifyFinished():void
Invoked when the connection is finished.
| NetServerConnection | ||
|
notifyNetServerEvent(type:String, status:NetServerStatus = null, info:* = null):void
Invoked when the connection is closed.
| NetServerConnection | ||
|
notifyStarted():void
Invoked when the connection is started.
| NetServerConnection | ||
|
notifyTimeOut():void
Invoked when the connection is timeout.
| NetServerConnection | ||
| Constant | Defined by | ||
|---|---|---|---|
| DEFAULT_DELAY : uint = 8000 [static]
The default internal timeout delay value in milliseconds.
| NetServerConnection | ||
| client | property |
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
| connected | property |
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
| connectedProxyType | property |
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
| defaultObjectEncoding | property |
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
| farID | property |
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
| farNonce | property |
farNonce:String [read-only]A value chosen substantially by Flash Media Server, unique to this connection.
Implementation public function get farNonce():String
| maxPeerConnections | property |
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
| nearID | property |
nearID:String [read-only]The identifier of this Flash Player or Adobe AIR instance for this NetConnection instance.
Implementation public function get nearID():String
| nearNonce | property |
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
| objectEncoding | property |
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
| protocol | property |
protocol:String [read-only]The protocol used to establish the connection.
Implementation public function get protocol():String
| proxyType | property |
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
| unconnectedPeerStreams | property |
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
| uri | property |
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
| usingTLS | property |
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
| NetServerConnection | () | constructor |
public function NetServerConnection(bGlobal:Boolean = false, sChannel:String = null)Creates a new NetServerConnection instance.
ParametersbGlobal: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.
|
| addHeader | () | method |
public function addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):voidAdds a context header to the AMF packet structure. This header is sent with every future AMF packet.
Parametersoperation: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):BooleanInvokes 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.
Parameterscommand: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.
|
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):BooleanCloses the connection that was opened locally or with the server and dispatches the netStatus event with a code property of NetConnection.Connect.Closed.
ParametersnoEvent:Boolean (default = false) |
Boolean — A boolean to indicates if the connection is closed.
|
| connect | () | method |
public function connect(command:String, ... arguments):voidConnect the client with this method.
Parameterscommand:String |
|
... arguments |
| getDelay | () | method |
public function getDelay():uintReturns timeout interval duration.
Returnsuint |
| getInstance | () | method |
public static function getInstance():NetServerConnectionReturns the singleton instance of class.
ReturnsNetServerConnection —
singleton instance of class.
|
| getTimeoutPolicy | () | method |
public function getTimeoutPolicy():TimeoutPolicyReturns the TimeoutPolicy value of this object.
ReturnsTimeoutPolicy —
the TimeoutPolicy value of this object.
|
See also
| notifyFinished | () | method |
protected function notifyFinished():voidInvoked when the connection is finished.
| notifyNetServerEvent | () | method |
protected function notifyNetServerEvent(type:String, status:NetServerStatus = null, info:* = null):voidInvoked when the connection is closed.
Parameterstype:String |
|
status:NetServerStatus (default = null) |
|
info:* (default = null) |
| notifyStarted | () | method |
protected function notifyStarted():voidInvoked when the connection is started.
| notifyTimeOut | () | method |
protected function notifyTimeOut():voidInvoked when the connection is timeout.
| run | () | method |
public function run(... arguments):voidRuns the process of this NetServerConnection.
Parameters... arguments |
| setDelay | () | method |
public function setDelay(n:Number, useSeconds:Boolean):voidSet timeout interval duration.
Parametersn:Number |
|
useSeconds:Boolean |
| setLimitPolicy | () | method |
public function setLimitPolicy(policy:TimeoutPolicy):voidUse limit timeout interval.
Parameterspolicy:TimeoutPolicy |
See also
| sharedEvent | () | method |
public function sharedEvent(event:* = null, context:* = null):voidUse this method to dispatch in FMS application an event.
Parametersevent:* (default = null) |
|
context:* (default = null) |
| toNetConnection | () | method |
public function toNetConnection():NetConnectionReturns the internal NetConnection reference of this object.
ReturnsNetConnection — the internal NetConnection reference of this object.
|
| DEFAULT_DELAY | constant |
public static const DEFAULT_DELAY:uint = 8000The default internal timeout delay value in milliseconds.