PHPRPC 3.0 for PHP API Draft

Server API:

constructor PHPRPC_Server();

Create the PHPRPC Server object.

add(string funcname);
add(string funcname, null, string alias);
add(string[] funcnames);
add(string[] funcnames, null, string[] aliases);
 
add(string funcname, object obj);
add(string funcname, object obj, string alias);
add(string[] funcnames, object obj);
add(string[] funcnames, object obj, string[] aliases);
 
add(string funcname, string classname);
add(string funcname, string classname, string alias);
add(string[] funcnames, string classname);
add(string[] funcnames, string classname, string[] aliases);

Add global functions, instance methods or static methods to the server. The functions or the methods can have aliases. This method must be called before start().

add(object obj);

Add all methods from obj to the server. This method must be called before start().

setCharset(string charset);

Set the charset of the server. This method must be called before start();

setDebugMode(boolean debug);

Set the debug mode of the server. This method must be called before start();

start();

Start the PHPRPC server. This method usually be called at the end of page. This method can NOT be called twice or more in one page.

Client API:

constructor PHPRPC_Client();
constructor PHPRPC_Client(string serverURL);

Create PHPRPC Client object. The serverURL supports using username and password for the HTTP Basic Authorization, but it is NOT recommend.

setProxy(string address);
setProxy(string host, string port);
setProxy(string host, string port, string username, string password);

Set the proxy server for the transfer. The address supports using username and password for the HTTP Basic Authorization, but it is NOT recommend. You can set the address to NULL to cancel the proxy server.

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

Set the URL of the PHPRPC Server. The serverURL supports using username and password for the HTTP Basic Authorization, but it is NOT recommend. You’d better to set username and password alone.

boolean setKeyLength(integer keyLength);

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

integer 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(integer 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.

integer getEncryptMode();

Get the encrypt mode.

setCharset(string charset);

Set the request charset. Use it before invoke the remote function. The default value is “UTF-8″ or as the response charset.

string getCharset();

Get the response charset. Use it after invoke the remote function.

setTimeout(int timeout);

Set the timeout of the invoking of the remote function. the timeout is the number of seconds. Default value is 30 seconds.

integer getTimeout();

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

invoke(string funcname, object[] args);
invoke(string funcname, object[] args, boolean byRef);

Invoke the server function with the function name and arguments array. if you want to transfer the arguments by reference, set byRef to be true.

remoteFunctionName(arg1, arg2, ..., argN);

Invoke the server function directly. You can’t transfer the arguments by reference in this mode.

string getOutput();

Get the output of the server console after invoke the server function.

PHPRPC_Error getWarning();

Get the warning of the server function after invoke the server function.

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 remote function.

integer getNumber();

return error number.

string getMessage();

return error message.

string toString();

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

标签: PHP, PHPRPC

« 上一篇 | 下一篇 »

只显示10条记录相关文章

发表评论

评论 (必须):