llviewergenericmessage.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 
00035 #include "llviewergenericmessage.h"
00036 
00037 #include "lldispatcher.h"
00038 #include "lluuid.h"
00039 #include "message.h"
00040 
00041 #include "llagent.h"
00042 
00043 
00044 LLDispatcher gGenericDispatcher;
00045 
00046 
00047 void send_generic_message(const char* method,
00048                                                   const std::vector<std::string>& strings,
00049                                                   const LLUUID& invoice)
00050 {
00051         LLMessageSystem* msg = gMessageSystem;
00052         msg->newMessage("GenericMessage");
00053         msg->nextBlockFast(_PREHASH_AgentData);
00054         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00055         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00056         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
00057         msg->nextBlock("MethodData");
00058         msg->addString("Method", method);
00059         msg->addUUID("Invoice", invoice);
00060         if(strings.empty())
00061         {
00062                 msg->nextBlock("ParamList");
00063                 msg->addString("Parameter", NULL);
00064         }
00065         else
00066         {
00067                 std::vector<std::string>::const_iterator it = strings.begin();
00068                 std::vector<std::string>::const_iterator end = strings.end();
00069                 for(; it != end; ++it)
00070                 {
00071                         msg->nextBlock("ParamList");
00072                         msg->addString("Parameter", (*it).c_str());
00073                 }
00074         }
00075         gAgent.sendReliableMessage();
00076 }
00077 
00078 
00079 
00080 void process_generic_message(LLMessageSystem* msg, void**)
00081 {
00082         LLUUID agent_id;
00083         msg->getUUID("AgentData", "AgentID", agent_id);
00084         if (agent_id != gAgent.getID())
00085         {
00086                 llwarns << "GenericMessage for wrong agent" << llendl;
00087                 return;
00088         }
00089 
00090         std::string request;
00091         LLUUID invoice;
00092         LLDispatcher::sparam_t strings;
00093         LLDispatcher::unpackMessage(msg, request, invoice, strings);
00094 
00095         if(!gGenericDispatcher.dispatch(request, invoice, strings))
00096         {
00097                 llwarns << "GenericMessage " << request << " failed to dispatch" 
00098                         << llendl;
00099         }
00100 }

Generated on Thu Jul 1 06:09:27 2010 for Second Life Viewer by  doxygen 1.4.7