LLSDRPCServer Class Reference

Basic implementation of a structure data rpc server. More...

#include <llsdrpcserver.h>

Inheritance diagram for LLSDRPCServer:

Inheritance graph
[legend]
Collaboration diagram for LLSDRPCServer:

Collaboration graph
[legend]

List of all members.

Public Types

enum  { FAULT_BAD_REQUEST = 2000, FAULT_NO_RESPONSE = 2001 }

Public Member Functions

 LLSDRPCServer ()
virtual ~LLSDRPCServer ()
void clearLock ()
 unlock a service that as ESDRPCS_DEFERRED

Static Public Member Functions

static void buildFault (const LLChannelDescriptors &channels, LLBufferArray *data, S32 code, const std::string &msg)
 Call this method to return an rpc fault.
static void buildResponse (const LLChannelDescriptors &channels, LLBufferArray *data, const LLSD &response)
 Call this method to build an rpc response.

Protected Types

enum  EState { STATE_NONE, STATE_CALLBACK, STATE_DEFERRED, STATE_DONE }
 Enumeration to track the state of the rpc server instance. More...
typedef std::map< std::string,
LLSDRPCMethodCallBase * > 
method_map_t

Protected Member Functions

virtual ESDRPCSStatus callMethod (const std::string &method, const LLSD &params, const LLChannelDescriptors &channels, LLBufferArray *data)
 This method is called when an http post comes in.
virtual ESDRPCSStatus callbackMethod (const std::string &method, const LLSD &params, const LLChannelDescriptors &channels, LLBufferArray *data)
 This method is called when a pump callback is processed.
virtual ESDRPCSStatus deferredResponse (const LLChannelDescriptors &channels, LLBufferArray *data)
 Called after a deferred service is unlocked.
virtual EStatus process_impl (const LLChannelDescriptors &channels, buffer_ptr_t &buffer, bool &eos, LLSD &context, LLPumpIO *pump)
 Process the data in buffer.

Protected Attributes

EState mState
LLSD mRequest
LLPumpIOmPump
S32 mLock
method_map_t mMethods
method_map_t mCallbackMethods


Detailed Description

Basic implementation of a structure data rpc server.

The rpc server is also designed to appropriately straddle the pump process() and callback() to specify which thread you want to work on when handling a method call. The mMethods methods are called from process(), while the mCallbackMethods are called when a pump is in a callback() cycle.

Definition at line 168 of file llsdrpcserver.h.


Member Typedef Documentation

typedef std::map<std::string, LLSDRPCMethodCallBase*> LLSDRPCServer::method_map_t [protected]

Definition at line 303 of file llsdrpcserver.h.


Member Enumeration Documentation

anonymous enum

enumeration for generic fault codes

Enumerator:
FAULT_BAD_REQUEST 
FAULT_NO_RESPONSE 

Definition at line 177 of file llsdrpcserver.h.

enum LLSDRPCServer::EState [protected]

Enumeration to track the state of the rpc server instance.

Enumerator:
STATE_NONE 
STATE_CALLBACK 
STATE_DEFERRED 
STATE_DONE 

Definition at line 229 of file llsdrpcserver.h.


Constructor & Destructor Documentation

LLSDRPCServer::LLSDRPCServer (  ) 

LLSDRPCServer

Definition at line 61 of file llsdrpcserver.cpp.

References LLMemType::MTYPE_IO_SD_SERVER.

LLSDRPCServer::~LLSDRPCServer (  )  [virtual]

Definition at line 69 of file llsdrpcserver.cpp.

References llcompose1(), mCallbackMethods, mMethods, and LLMemType::MTYPE_IO_SD_SERVER.

Here is the call graph for this function:


Member Function Documentation

void LLSDRPCServer::buildFault ( const LLChannelDescriptors channels,
LLBufferArray data,
S32  code,
const std::string &  msg 
) [static]

Call this method to return an rpc fault.

Parameters:
channel The channel for output on the data buffer
data buffer which will recieve the final output
code The fault code
msg The fault message

Definition at line 319 of file llsdrpcserver.cpp.

References FAULT_PART_1, FAULT_PART_2, FAULT_PART_3, llendl, llinfos, and LLMemType::MTYPE_IO_SD_SERVER.

Referenced by callbackMethod(), callMethod(), and process_impl().

Here is the caller graph for this function:

void LLSDRPCServer::buildResponse ( const LLChannelDescriptors channels,
LLBufferArray data,
const LLSD response 
) [static]

Call this method to build an rpc response.

Parameters:
channel The channel for output on the data buffer
data buffer which will recieve the final output
response The return value from the method call

Definition at line 332 of file llsdrpcserver.cpp.

References llendl, llinfos, LLMemType::MTYPE_IO_SD_SERVER, RESPONSE_PART_1, RESPONSE_PART_2, and LLSDSerialize::toNotation().

Referenced by tut::rpc_server_data::LLSimpleRPCServer::rpc_Echo().

Here is the call graph for this function:

Here is the caller graph for this function:

LLIOPipe::EStatus LLSDRPCServer::process_impl ( const LLChannelDescriptors channels,
buffer_ptr_t buffer,
bool &  eos,
LLSD context,
LLPumpIO pump 
) [protected, virtual]

ESDRPCSStatus LLSDRPCServer::callMethod ( const std::string &  method,
const LLSD params,
const LLChannelDescriptors channels,
LLBufferArray data 
) [protected, virtual]

This method is called when an http post comes in.

The default behavior is to look at the method name, look up the method in the method table, and call it. If the method is not found, this function will build a fault response. You can implement your own version of this function if you want to hard wire some behavior or optimize things a bit.

Parameters:
method The method name being called
params The parameters
channel The channel for output on the data buffer
data The http data
Returns:
Returns the status of the method call, done/deferred/etc

Definition at line 252 of file llsdrpcserver.cpp.

References buildFault(), ESDRPCS_CALLBACK, ESDRPCS_DONE, FAULT_METHOD_NOT_FOUND, mCallbackMethods, mMethods, and LLMemType::MTYPE_IO_SD_SERVER.

Referenced by process_impl().

Here is the call graph for this function:

Here is the caller graph for this function:

ESDRPCSStatus LLSDRPCServer::callbackMethod ( const std::string &  method,
const LLSD params,
const LLChannelDescriptors channels,
LLBufferArray data 
) [protected, virtual]

This method is called when a pump callback is processed.

The default behavior is to look at the method name, look up the method in the callback method table, and call it. If the method is not found, this function will build a fault response. You can implement your own version of this function if you want to hard wire some behavior or optimize things a bit.

Parameters:
method The method name being called
params The parameters
channel The channel for output on the data buffer
data The http data
Returns:
Returns the status of the method call, done/deferred/etc

Definition at line 291 of file llsdrpcserver.cpp.

References buildFault(), ESDRPCS_DONE, FAULT_METHOD_NOT_FOUND, mCallbackMethods, and LLMemType::MTYPE_IO_SD_SERVER.

Referenced by process_impl().

Here is the call graph for this function:

Here is the caller graph for this function:

ESDRPCSStatus LLSDRPCServer::deferredResponse ( const LLChannelDescriptors channels,
LLBufferArray data 
) [protected, virtual]

Called after a deferred service is unlocked.

If a method returns ESDRPCS_DEFERRED, then the service chain will be locked and not processed until some other system calls clearLock() on the service instance again. At that point, once the pump starts processing the chain again, this method will be called so the service can output the final result into the buffers.

Definition at line 88 of file llsdrpcserver.cpp.

References ESDRPCS_DONE.

Referenced by process_impl().

Here is the caller graph for this function:

void LLSDRPCServer::clearLock (  ) 

unlock a service that as ESDRPCS_DEFERRED

Definition at line 95 of file llsdrpcserver.cpp.

References LLPumpIO::clearLock(), mLock, mPump, and NULL.

Here is the call graph for this function:


Member Data Documentation

Definition at line 299 of file llsdrpcserver.h.

Referenced by process_impl().

Definition at line 300 of file llsdrpcserver.h.

Referenced by process_impl().

Definition at line 301 of file llsdrpcserver.h.

Referenced by clearLock(), and process_impl().

Definition at line 302 of file llsdrpcserver.h.

Referenced by clearLock(), and process_impl().

Definition at line 305 of file llsdrpcserver.h.

Referenced by callbackMethod(), callMethod(), and ~LLSDRPCServer().


The documentation for this class was generated from the following files:

Generated on Fri May 16 09:03:43 2008 for SecondLife by  doxygen 1.5.5