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

 FAULT_BAD_REQUEST = 2000
 FAULT_NO_RESPONSE = 2001
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

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

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.


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 316 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().

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 329 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().

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 288 of file llsdrpcserver.cpp.

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

Referenced by process_impl().

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 249 of file llsdrpcserver.cpp.

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

Referenced by process_impl().

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.

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

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

Process the data in buffer.

Definition at line 106 of file llsdrpcserver.cpp.

References LLSD::asString(), buildFault(), callbackMethod(), callMethod(), LLSD::clear(), LLPumpIO::clearLock(), deferredResponse(), ESDRPCS_CALLBACK, ESDRPCS_DEFERRED, ESDRPCS_DONE, ESDRPCS_ERROR, FAULT_GENERIC, LLSDSerialize::fromNotation(), LLSD::has(), LLSDRPC_METHOD_SD_NAME(), LLSDRPC_PARAMETER_SD_NAME(), LLPumpIO::LLLinkInfo::mChannels, mLock, LLPumpIO::LLLinkInfo::mPipe, mPump, mRequest, mState, LLMemType::MTYPE_IO_SD_SERVER, PUMP_DEBUG, LLPumpIO::respond(), LLPumpIO::setLock(), STATE_CALLBACK, STATE_DEFERRED, STATE_DONE, STATE_NONE, LLIOPipe::STATUS_BREAK, LLIOPipe::STATUS_DONE, and LLIOPipe::STATUS_PRECONDITION_NOT_MET.


Member Data Documentation

method_map_t LLSDRPCServer::mCallbackMethods [protected]

Definition at line 305 of file llsdrpcserver.h.

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

S32 LLSDRPCServer::mLock [protected]

Definition at line 302 of file llsdrpcserver.h.

Referenced by clearLock(), and process_impl().

method_map_t LLSDRPCServer::mMethods [protected]

Definition at line 304 of file llsdrpcserver.h.

Referenced by callMethod(), tut::rpc_server_data::LLSimpleRPCServer::LLSimpleRPCServer(), and ~LLSDRPCServer().

LLPumpIO* LLSDRPCServer::mPump [protected]

Definition at line 301 of file llsdrpcserver.h.

Referenced by clearLock(), and process_impl().

LLSD LLSDRPCServer::mRequest [protected]

Definition at line 300 of file llsdrpcserver.h.

Referenced by process_impl().

EState LLSDRPCServer::mState [protected]

Definition at line 299 of file llsdrpcserver.h.

Referenced by process_impl().


The documentation for this class was generated from the following files:
Generated on Thu Jul 1 06:11:45 2010 for Second Life Viewer by  doxygen 1.4.7