diff options
Diffstat (limited to 'linden/indra/newview/llviewergenericmessage.cpp')
-rw-r--r-- | linden/indra/newview/llviewergenericmessage.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewergenericmessage.cpp b/linden/indra/newview/llviewergenericmessage.cpp new file mode 100644 index 0000000..56b168b --- /dev/null +++ b/linden/indra/newview/llviewergenericmessage.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | /** | ||
2 | * @file llviewergenericmessage.cpp | ||
3 | * @brief Handle processing of "generic messages" which contain short lists of strings. | ||
4 | * @author James Cook | ||
5 | * | ||
6 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * Second Life Viewer Source Code | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #include "llviewerprecompiledheaders.h" | ||
31 | |||
32 | #include "llviewergenericmessage.h" | ||
33 | |||
34 | #include "lldispatcher.h" | ||
35 | #include "lluuid.h" | ||
36 | #include "message.h" | ||
37 | |||
38 | #include "llagent.h" | ||
39 | |||
40 | |||
41 | LLDispatcher gGenericDispatcher; | ||
42 | |||
43 | |||
44 | void send_generic_message(const char* method, | ||
45 | const std::vector<std::string>& strings, | ||
46 | const LLUUID& invoice) | ||
47 | { | ||
48 | LLMessageSystem* msg = gMessageSystem; | ||
49 | msg->newMessage("GenericMessage"); | ||
50 | msg->nextBlockFast(_PREHASH_AgentData); | ||
51 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
52 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
53 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | ||
54 | msg->nextBlock("MethodData"); | ||
55 | msg->addString("Method", method); | ||
56 | msg->addUUID("Invoice", invoice); | ||
57 | if(strings.empty()) | ||
58 | { | ||
59 | msg->nextBlock("ParamList"); | ||
60 | msg->addString("Parameter", NULL); | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | std::vector<std::string>::const_iterator it = strings.begin(); | ||
65 | std::vector<std::string>::const_iterator end = strings.end(); | ||
66 | for(; it != end; ++it) | ||
67 | { | ||
68 | msg->nextBlock("ParamList"); | ||
69 | msg->addString("Parameter", (*it).c_str()); | ||
70 | } | ||
71 | } | ||
72 | gAgent.sendReliableMessage(); | ||
73 | } | ||
74 | |||
75 | |||
76 | |||
77 | void process_generic_message(LLMessageSystem* msg, void**) | ||
78 | { | ||
79 | LLUUID agent_id; | ||
80 | msg->getUUID("AgentData", "AgentID", agent_id); | ||
81 | if (agent_id != gAgent.getID()) | ||
82 | { | ||
83 | llwarns << "GenericMessage for wrong agent" << llendl; | ||
84 | return; | ||
85 | } | ||
86 | |||
87 | std::string request; | ||
88 | LLUUID invoice; | ||
89 | LLDispatcher::sparam_t strings; | ||
90 | LLDispatcher::unpackMessage(msg, request, invoice, strings); | ||
91 | |||
92 | if(!gGenericDispatcher.dispatch(request, invoice, strings)) | ||
93 | { | ||
94 | llwarns << "GenericMessage " << request << " failed to dispatch" | ||
95 | << llendl; | ||
96 | } | ||
97 | } | ||