[AS3] Class r1.rpc.RPC |
Client API |
| Package | r1.rpc |
| Class | public class RPC |
| Inheritance | RPC flash.events.EventDispatcher |
An instance of this class represents a remote service end point, which is a configured servlet instance.
Usually an application needs just one service end point.
This class has a singleton, defaultRPC, which is
typically initialized by a call to initSingleRPC()).
See also
| Property | Defined by | ||
|---|---|---|---|
| authFailurePolicy : String = "as_usual" [static]
The policy for authorization failure.
| RPC | ||
| defaultRPC : RPC
[static]
The singleton RPC object.
| RPC | ||
| passwordEncrypted : Boolean = true
If set to
true, use CHAP login, where only dynamic
digests are sent across the wire. | RPC | ||
| pollingMaxDelaySeconds : int [write-only]
The longest delay between polling, in minutes.
| RPC | ||
| rpcEncoding : int = 1
The RPC data encoding.
| RPC | ||
| rpcUrl : String = "null"
The URL for this RPC interface.
| RPC | ||
| Method | Defined by | ||
|---|---|---|---|
|
RPC(url:String, encoding:int, sessionNeverTimeout:Boolean = true)
Constructor.
| RPC | ||
|
changePassword(cb:Function, id:String, oldpw:String, newpw:String):void
To change a user's password.
| RPC | ||
|
digest(password:String):String
| RPC | ||
|
initSingleRPC(url:String, encoding:int, sessionNeverTimeout:Boolean = true):void
[static]
Initializes the
defaultRPC singleton instance. | RPC | ||
|
login(receiver:*, id:String, password:String):void
Authenticates the user identified by
id and password
by invoking the login handler on the server-side (which is a Java class that
extends the r1.rpc.LoginHandler class whose class name is
specified by the loginHandlerClass init-parameter) to establish
the server-side user session and returns an object representing the user. | RPC | ||
|
logout(cb:Function = null):void
Clears the server session.
| RPC | ||
|
ping():void
To ping the server to keep session alive and fetch waiting messages, if any.
| RPC | ||
|
registerUser(cb:Function, id:String, password:String, userData:Object):void
To register a new user.
| RPC | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when the server messages are received. | RPC | |||
| Dispatched in one of the three situations: (1) when a remote call to an authorized method failed authorization, for instance, the user has not logged on yet; (2) logging in failed; and (3) registering new user (using CHAP) failed. | RPC | |||
| Constant | Defined by | ||
|---|---|---|---|
| AUTH_FAIL_AS_USUAL : String = "as_usual" [static]
| RPC | ||
| AUTH_FAIL_SILIENCE : String = "silence" [static]
| RPC | ||
| RPC_BINARY : int = 2 [static]
A constant indicating to use binary message encoding.
| RPC | ||
| RPC_DEFAULT : int = 0 [static]
A constant indicating to use the default message encoding.
| RPC | ||
| RPC_ENCRYPTED : int = 3 [static]
A constant indicating to use encrypted binary message encoding.
| RPC | ||
| RPC_JSON : int = 1 [static]
A constant indicating to use JSON textual message encoding.
| RPC | ||
| authFailurePolicy | property |
public static var authFailurePolicy:String = "as_usual"
The policy for authorization failure. By default it is
AUTH_FAIL_AS_USUAL, which means an authentication failure
is treated as a normal server-side exception. The other value is
AUTH_FAIL_SILENCE, where the failure is simply ignored.
| defaultRPC | property |
public static var defaultRPC:RPC
The singleton RPC object. If a fa¸ade class is initialized with
a null RPC, then this instance is used.
See also
| passwordEncrypted | property |
public var passwordEncrypted:Boolean = true
If set to true, use CHAP login, where only dynamic
digests are sent across the wire.
Otherwise, passwords are passed to server as plain text.
| pollingMaxDelaySeconds | property |
pollingMaxDelaySeconds:int [write-only]The longest delay between polling, in minutes. If this is set to be greater than 0, polling to server is started. A polling happens automatically during a remote method call, and the server message is piggybacked in the result. Therefore the actual server message polling can happen more frequently than this period.
Implementation public function set pollingMaxDelaySeconds(value:int):void
| rpcEncoding | property |
public var rpcEncoding:int = 1The RPC data encoding.
| rpcUrl | property |
public var rpcUrl:String = "null"The URL for this RPC interface. It can be absolute or relative.
| RPC | () | constructor |
public function RPC(url:String, encoding:int, sessionNeverTimeout:Boolean = true)Constructor.
Parametersurl:String — the URL for this RPC interface. It can be absolute or relative.
|
|
encoding:int — the RPC data encoding.
|
|
sessionNeverTimeout:Boolean (default = true) — when true, if the server initialization returns
a session timeout value, the client-side will periodically connect
to the server so that the server session never times out.
|
| call | () | method |
r1_internal function call(encoding:int, facadeName:String, methodName:String, args:Array, receiver:*):voidParameters
encoding:int — can be one of the following three possibilities:
|
|
facadeName:String |
|
methodName:String |
|
args:Array |
|
receiver:* |
| changePassword | () | method |
public function changePassword(cb:Function, id:String, oldpw:String, newpw:String):voidTo change a user's password. This is usually used for systems using, CHAP login, where password digest is sent to the server.
Parameterscb:Function — the new user's ID. It can be null, where the server
should create one and return it.
|
|
id:String — a normal RPC callback, whose signature is:
function cb(id:String, res:RPCResult):void;
|
|
oldpw:String — the old password, in plain-text.
|
|
newpw:String — the new password, in plain-text.
|
| digest | () | method |
public function digest(password:String):StringParameters
password:String |
String |
| initSingleRPC | () | method |
public static function initSingleRPC(url:String, encoding:int, sessionNeverTimeout:Boolean = true):void
Initializes the defaultRPC singleton instance.
In most applications, a single RPC interface suffices, so a call
to this function at the start of the application is all you need.
url:String |
|
encoding:int |
|
sessionNeverTimeout:Boolean (default = true) |
| login | () | method |
public function login(receiver:*, id:String, password:String):void
Authenticates the user identified by id and password
by invoking the login handler on the server-side (which is a Java class that
extends the r1.rpc.LoginHandler class whose class name is
specified by the loginHandlerClass init-parameter) to establish
the server-side user session and returns an object representing the user.
receiver:* — can be one of the following three possibilities:
|
|
id:String |
|
password:String |
| logout | () | method |
public function logout(cb:Function = null):voidClears the server session.
Parameterscb:Function (default = null) — this usual RPC callback is used to clear the client-side state.
If specified, it is called synchronously. Its signature is:
callback(any:null, rpcResult:RPCResult):void {}
|
| ping | () | method |
public function ping():voidTo ping the server to keep session alive and fetch waiting messages, if any.
| registerUser | () | method |
public function registerUser(cb:Function, id:String, password:String, userData:Object):voidTo register a new user.
Parameterscb:Function — the new user's ID. It can be null, where the server
should create one and return it.
|
|
id:String — a normal RPC callback, whose signature is:
function cb(id:String, res:RPCResult):void;
The return value is the user ID. If the ID was sent the server,
on successful registration, the same ID is returned; or an
authentication error will occur if the same ID exists.
If no ID was sent, the server should create one and return here;
The client should save this ID.
|
|
password:String — user's password.
|
|
userData:Object — extra user information. This can be a generic Object or a
VO object that the server side expects.
|
| message | event |
| SERVER_AUTH_FAILURE | event |
r1.rpc.ErrorResult
Dispatched in one of the three situations: (1) when a remote call to an authorized method failed authorization, for instance, the user has not logged on yet; (2) logging in failed; and (3) registering new user (using CHAP) failed.
| AUTH_FAIL_AS_USUAL | constant |
| AUTH_FAIL_SILIENCE | constant |
| RPC_BINARY | constant |
public static const RPC_BINARY:int = 2A constant indicating to use binary message encoding. (To be implemented)
| RPC_DEFAULT | constant |
public static const RPC_DEFAULT:int = 0A constant indicating to use the default message encoding.
| RPC_ENCRYPTED | constant |
public static const RPC_ENCRYPTED:int = 3A constant indicating to use encrypted binary message encoding. (To be implemented)
| RPC_JSON | constant |
public static const RPC_JSON:int = 1A constant indicating to use JSON textual message encoding.
flash.events.EventDispatcher