PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/lltemplatemessagedispatcher.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 67 lines | 32 code | 10 blank | 25 comment | 4 complexity | eeaf02ac7f58da38ce0a0e11da40881e MD5 | raw file
 1/**
 2 * @file lltemplatemessagedispatcher.h
 3 * @brief LLTemplateMessageDispatcher class
 4 *
 5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27
28#include "lltemplatemessagedispatcher.h"
29
30#include "llhttpnode.h"
31#include "llhost.h"
32#include "message.h"
33#include "llsd.h"
34#include "lltemplatemessagereader.h"
35
36
37LLTemplateMessageDispatcher::LLTemplateMessageDispatcher(LLTemplateMessageReader &template_message_reader) :
38	mTemplateMessageReader(template_message_reader)
39{
40}
41
42void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
43										   const LLSD& message,
44										   LLHTTPNode::ResponsePtr responsep)
45{
46	std::vector<U8> data = message["body"]["binary-template-data"].asBinary();
47	U32 size = data.size();
48	if(size == 0)
49	{
50		return;
51	}
52
53	LLHost host;
54	host = gMessageSystem->getSender();
55
56	bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), data.size(), host, true);
57
58	if (validate_message)
59	{
60		mTemplateMessageReader.readMessage(&(data[0]),host);
61	} 
62	else 
63	{
64		gMessageSystem->clearReceiveState();
65	}
66}
67