PHPRPC 3.0 for JavaScript Client API Draft

constructor PHPRPC_Client();
constructor PHPRPC_Client(string serverURL);
constructor PHPRPC_Client(string serverURL, array functions);
constructor PHPRPC_Client.create();
constructor PHPRPC_Client.create(string serverURL);
constructor PHPRPC_Client.create(string serverURL, array functions);

Create PHPRPC Client object. The username and password can be contained in serverURL for HTTP Basic Authorization, but it is NOT recommended (see also useService method for the recommended usage). To use create method create PHPRPC Client object in VBScript.

If you hope that the PHPRPC Client initialize remote functions without connecting to the PHPRPC Server, you can use the parameter functions.

useService(string serverURL);
useService(string serverURL, string username, string password);
useService(string serverURL, string username, string password, array functions);

Set the URL of the PHPRPC Server. The username and password can be contained in serverURL for HTTP Basic Authorization, but it is NOT recommended. It is recommended to specify the username and password by parameters.

If you hope that the PHPRPC Client initialize remote functions without connecting to the PHPRPC Server, you can use the parameter functions.

boolean setKeyLength(int keyLength);

Set the key length for the key exchange. This method will return false when the key exchange already to be done.

int getKeyLength();

Get the key length. This method will return actual value when the key exchange being done. Otherwise, you will get the default length or which length you set.

boolean setEncryptMode(int encryptMode);

Set the encrypt mode. 0 denotes no encrypting any data. 1 denotes encrypting arguments in the transfer. 2 denotes encrypting arguments and result. 3 denotes encrypting arguments, result and output of the server console. Set other value, it would return false.

int getEncryptMode();

Get the encrypt mode.

string remoteFunctionName(arg1, arg2, ..., argN);
string remoteFunctionName(arg1, arg2, ..., argN, callbackFunction);
string remoteFunctionName(arg1, arg2, ..., argN, callbackFunction, byRef);

Invoke the server function directly. The return value is remoteFunctionID, you can use abort method to abort the remoteFunction with this value. You can specify a callbackFunction, when the remote function completed, this callbackFunction will be call automatically. If you want to transfer the arguments by reference, set byRef to be true. If you didn’t specify a callbackFunction, the default callback function is remoteFunctionName_callback(), You can define it separately. the callbackFunction can be defined like this:

callbackFunction = function (result, args, output, warning) {
   ...
}

The parameter result is the remote function result, when an error occurred during invoking remote function, this parameter is a PHPRPC_Error object. The parameter args is the remote function arguments, you can get the changed arguments with it when transfering the arguments by reference. The parameter output is the output of the server console after invoke the remote function. The parameter warning is the warning of the server function after invoke the remote function, it is a PHPRPC_Error object.

onready();

This is a event. When the useService method completes, this event will be fired.

boolean getReady();

When the useService method completes, this method return true, otherwise return false.

string invoke(remoteFunctionName, arg1, arg2, ..., argN);
string invoke(remoteFunctionName, arg1, arg2, ..., argN, callbackFunction);
string invoke(remoteFunctionName, arg1, arg2, ..., argN, callbackFunction, byRef);

This method is similar to remoteFunctionName in calling remote function. The difference is the invoke method is available before the ready property becomes true, that is to say, this method can be called immediately after using useService method.

abort();
abort(string remoteFunctionID);

If you used this method without parameter, it would stop all of the remote functions. If you specified the remoteFunctionID, it would only stop the remote function you specified.

setTimeout(int timeout);

Set the timeout of the invoking of the remote function. the timeout is the number of milliseconds. Default value is 30 seconds. If you want to disable timeout, set timeout to 0 or null.

int getTimeout();

Get the timeout of the invoking the remote function. the return value is the number of milliseconds.

constructor PHPRPC_Error(int errno, string errstr);

You never need to create PHPRPC_Error object by yourself, when an error occurred during invoking remote function, this object will be created automatically as the result of callback function.

int getNumber();

return error number.

string getMessage();

return error message.

string toString();

return a string which include the error number and error message.

标签: JavaScript, PHPRPC

« 上一篇 | 下一篇 »

只显示10条记录相关文章

发表评论

评论 (必须):