Package | com.mi.rs |
Class | public class RSService |
Inheritance | RSService ![]() |
Implements | IService |
See also
Property | Defined By | ||
---|---|---|---|
baseURL : String [read-only]
|
RSService | ||
connectorName : String [read-only]
Returns the name of the current connector.
|
RSService | ||
defaultStateData : IStateData
The default state data for this IService instance.
|
RSService | ||
json : JSON [static] [read-only]
|
RSService | ||
RTMPCommandRate : int The number of times per second that command callbacks will be
processed when the RTMP connector is used.
|
RSService |
Method | Defined By | ||
---|---|---|---|
RSService(host:String, httpPort:int, defaultStateData:IStateData = null)
Creates an HTTP based implementation of the IService interface.
|
RSService | ||
addCallback(callback:Function, stateData:IStateData = null, delayProcessing:Boolean = false):void
Adds a callback to the end of the callback queue.
|
RSService | ||
addCommand(cmd:ICommand, responseHandler:Function = null, stateData:IStateData = null, delayProcessing:Boolean = false):void
Adds a command to be processed.
|
RSService | ||
cancelCallback(callback:Function):Boolean
Cancels a registered process commands callback.
|
RSService | ||
createJsonRequest(name:String, params:Object, id:int = 0):Object
[static]
Creates a JSON-RPC object from the given parameters suitable to
be stringified by the JSON class.
|
RSService | ||
createNetStream():NetStream
Creates a NetStream object that can be used to play RealityServer
video streams.
|
RSService | ||
createRandomString(length:int):String
[static]
Creates a random string of the given length using the
characters 0-9, and a-z.
|
RSService | ||
disableRTMP():void
Disables the RTMP connector and switches back to the HTTP
connector.
|
RSService | ||
enableRTMP(port:uint = 1935, stateData:IStateData = null):void
Attempts to connect to RealityServer using the rtmp protocol
by connecting to the specified port.
|
RSService |
Constant | Defined By | ||
---|---|---|---|
CLIENT_SIDE_ERROR_CODE_CONNECTION : int = -5100 [static] The response error code for commands that could not be processed
because of a connection error.
|
RSService | ||
CLIENT_SIDE_ERROR_CODE_INTERNAL : int = -5000 [static] The response error code for commands that could not be processed
because of an internal client side library error.
|
RSService | ||
HTTP_CONNECTOR_NAME : String = HTTP [static]
|
RSService | ||
RTMP_CONNECTOR_NAME : String = RTMP [static]
|
RSService |
baseURL | property |
baseURL:String
[read-only]
public function get baseURL():String
connectorName | property |
connectorName:String
[read-only]
Returns the name of the current connector. The connector encapsulates the on-the-wire protocol used to process commands. Currently two connectors are available:
"HTTP" - Commands are processed using HTTP requests. "RTMP" - Commands are processed using a RTMP connection.
RTMP specific commands are only available when the RTMP connector is used. public function get connectorName():String
defaultStateData | property |
defaultStateData:IStateData
The default state data for this IService instance. If no state data is specified in the addCommand and addCallback methods, then this is the state data that will be used.
public function get defaultStateData():IStateData
public function set defaultStateData(value:IStateData):void
json | property |
RTMPCommandRate | property |
RTMPCommandRate:int
The number of times per second that command callbacks will be processed when the RTMP connector is used.
public function get RTMPCommandRate():int
public function set RTMPCommandRate(value:int):void
RSService | () | Constructor |
public function RSService(host:String, httpPort:int, defaultStateData:IStateData = null)
Creates an HTTP based implementation of the IService interface.
Parameters
host:String — The host name or IP number of the service.
|
|
httpPort:int — The service port to use.
|
|
defaultStateData:IStateData (default = null ) — The state data that represents the default state.
|
See also
addCallback | () | method |
public function addCallback(callback:Function, stateData:IStateData = null, delayProcessing:Boolean = false):void
Adds a callback to the end of the callback queue. The callback will be made at the point in time when the service is ready to process commands generated by this callback. Callbacks will always be made in the order they were registered with the service, so if callback A is added before callback B, then A will be called before B and consequently any commands added by A will be processed before any commands added by B.
Callbacks are one-shot, meaning that a callback needs to be registered every time the application needs to process commands. The same callback can only be registered once at a time. The application is responsible for keeping track of any user input that occurs while waiting for the callback and convert that user input into an optimized sequence of NWS commands. The same callback function can be added again as soon as it has been called or cancelled.
NOTE: When the callback is made the supplied ICommandSequence instance must be used to add the commands, not IService.addCommand().
Parameters
callback:Function — The callback function. This function needs to
have the following signature:
addCommands(cmds:ICommandSequence):void
|
|
stateData:IStateData (default = null ) — The instance containing the state data for the
added commands. If no state data is added then the default
state data will be used.
|
|
delayProcessing:Boolean (default = false ) — This flag instructs the service if it
should delay processing of the added callback or not.
This flag should normally be left to its default value.
|
addCommand | () | method |
public function addCommand(cmd:ICommand, responseHandler:Function = null, stateData:IStateData = null, delayProcessing:Boolean = false):void
Adds a command to be processed.
Note that adding commands using this method is equivalent to registering a process commands callback and adding commands when the process commands callback is made. This means that any callbacks already registered will be executed before the command (or commands if the delayProcessing flag is used) added using this method.
Example: Adding commands A, B, and C with delayProcessing set to true for A and B, but false for C will be equivalent to register a callback and add A, B, and C when the callback is made.
Parameters
cmd:ICommand — The command to add.
|
|
responseHandler:Function (default = null ) — The optional function that will be called
when the
command has been processed. The callback function must have the
following signature:
function responseHandler(resp:IResponse):void
|
|
stateData:IStateData (default = null ) — The instance containing the state data of the
added command. If no state data is added then the default state
data will be used.
|
|
delayProcessing:Boolean (default = false ) — A hint that tells the service not to try
to send the command immediately. This hint is useful when adding
a sequence of commands in one go. Specifying this flag to true
for all commands except the last one added will ensure that the
Service don't start processing the events until the entire
sequence has been added, which is more efficient in some
cases.
|
See also
cancelCallback | () | method |
public function cancelCallback(callback:Function):Boolean
Cancels a registered process commands callback. This call removes the callback from the queue. Useful if the callback is no longer needed, or if the callback needs to be moved to the end of the queue. In the latter case, first cancelling and then adding the callback makse sure that it is executed after any callbacks already in the callback queue.
Parameters
callback:Function — The previously added callback function.
|
Boolean — true if the callback was cancelled, false if it was not
in the queue.
|
createJsonRequest | () | method |
public static function createJsonRequest(name:String, params:Object, id:int = 0):Object
Creates a JSON-RPC object from the given parameters suitable to be stringified by the JSON class.
Parameters
name:String |
|
params:Object |
|
id:int (default = 0 )
|
Object |
createNetStream | () | method |
public function createNetStream():NetStream
Creates a NetStream object that can be used to play RealityServer video streams.
ReturnsNetStream |
createRandomString | () | method |
public static function createRandomString(length:int):String
Creates a random string of the given length using the characters 0-9, and a-z.
Parameters
length:int |
String — A random string of the specified length.
|
disableRTMP | () | method |
public function disableRTMP():void
Disables the RTMP connector and switches back to the HTTP connector.
enableRTMP | () | method |
public function enableRTMP(port:uint = 1935, stateData:IStateData = null):void
Attempts to connect to RealityServer using the rtmp protocol by connecting to the specified port. If successful a RSService.CONNECTOR_CHANGED_EVENT will be dispatched at which point the RTMP connector is used and RTMP specific commands will be available. If the connection fails a RSService.RTMP_CONNECTION_ERROR_EVENT will be dispatched. An error will be thrown if this method is called if RTMP has already been enabled. Call disableRTMP before calling this method again.
Parameters
port:uint (default = 1935 ) — The port of the RTMP service.
|
|
stateData:IStateData (default = null ) — Optional state data containing a path and
rtmp URL parameters. If not specified the default state
will be used.
|
CLIENT_SIDE_ERROR_CODE_CONNECTION | Constant |
public static const CLIENT_SIDE_ERROR_CODE_CONNECTION:int = -5100
The response error code for commands that could not be processed because of a connection error. Client side errors are in the range -5000 to -5999.
CLIENT_SIDE_ERROR_CODE_INTERNAL | Constant |
public static const CLIENT_SIDE_ERROR_CODE_INTERNAL:int = -5000
The response error code for commands that could not be processed because of an internal client side library error. Client side errors are in the range 5000 to 5999.
HTTP_CONNECTOR_NAME | Constant |
public static const HTTP_CONNECTOR_NAME:String = HTTP
RTMP_CONNECTOR_NAME | Constant |
public static const RTMP_CONNECTOR_NAME:String = RTMP