2 ### rpc message frame format
4 The rpc message format is defined like below.
12 //function:push (push bytes data to server and put the reference into slot addressed by dest_addr.)
13 //Explain in C, *dest_addr=&data
16 uint8_t opcode; // "opcode" identify the type of the request. for push_request,this value is 1
19 } session; /* "session" is an identifier established by the client.
20 The Server MUST reply "session" with the same value in the Response struct for ALL request types */
31 } session; // MUST be the same as the value of "session" in request
34 //function:pull (pull bytes data refered by the reference in slot addressed by src_addr.)
35 //Explain in C, return **src_addr
51 uint32_t length; // 0XFFFFFFFF(-1) if data can't be transfered,In this case, sizeof(data)==0
54 //function:assign (set slot value.)
55 //Explain in C, *dest_addr=*src_addr
56 struct assign_request{
65 struct assign_response{
73 //function:unlink (set slot to NULL.)
74 // Explain in C, *dest_addr=NULL
75 //server may decide if the resources can be free.
76 struct unlink_request{
84 struct unlink_response{
92 //function:call (invoke function stored in func_addr.)
93 //Explain in C, *dest_addr=(*func_addr)(param1,param2...)
94 //PxpRpc assume the client always know the definition of the function.
95 //So wrong parameter may BREAK the PxpRpc connection permanently.
109 struct call_response{
117 //In general(but not necessary), return value are defined like below.
118 struct call_response{
124 #if FUNCTION_RETURN_32BIT
125 //function return boolean,int32,float32.
126 //if function is supposed to return an object,
127 //returnValue=0 to indicate the sucess(In this case, dest_addr will store the return object),
128 //returnValue=1 to indicate the fault(In this case, dest_addr will store an Exception).
129 uint32_t returnValue;
130 #elif FUNCTION_RETURN_64BIT
131 //funcion return int64,float64
132 uint64_t returnValue;
136 //function:getFunc (get builtin function named by string refered by func_name_addr.)
137 //Explain in C,*dest_addr=getFunction(*func_name_addr)
138 //func_name_addr can be a slot where stored the reference to a utf8 encode string pushed previously.
139 struct getFunc_request{
146 uint32_t func_name_addr;
148 struct getFunc_response{
154 uint32_t dest_addr; // 0 if function not found
157 //function:close (free the resource and prepare to disconnect)
158 struct close_request{
165 //closed, No response.
167 //function:getInfo (get string encoded in utf8 indicate the information about the server.)
168 struct getInfo_request{
175 struct getInfo_response{
181 uint32_t length; // 0XFFFFFFFF(-1) if data can't be transfered,In this case, sizeof(data)==0
185 "data" stored the information about the server (as utf8). An example "data" show below
186 -----------------------------
187 server name:pxprpc for java
189 reference slots size:256
190 -------------------------------
191 "server name" indicate the server name.
192 "version" indicate the pxprpc protocol version. Currently only 1.0 is valid.
193 "reference slots capacity" indicate how many slots can client use. Client should ensure that the slot address is less than this value.
197 the server should take responsibility for the lifecycle manager of the objects referred by references slots.
198 When an object have no reference refer to, server should free it.