PageRenderTime 33ms CodeModel.GetById 12ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #include "lltemplatemessagedispatcher.h"
  27. #include "llhttpnode.h"
  28. #include "llhost.h"
  29. #include "message.h"
  30. #include "llsd.h"
  31. #include "lltemplatemessagereader.h"
  32. LLTemplateMessageDispatcher::LLTemplateMessageDispatcher(LLTemplateMessageReader &template_message_reader) :
  33. mTemplateMessageReader(template_message_reader)
  34. {
  35. }
  36. void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
  37. const LLSD& message,
  38. LLHTTPNode::ResponsePtr responsep)
  39. {
  40. std::vector<U8> data = message["body"]["binary-template-data"].asBinary();
  41. U32 size = data.size();
  42. if(size == 0)
  43. {
  44. return;
  45. }
  46. LLHost host;
  47. host = gMessageSystem->getSender();
  48. bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), data.size(), host, true);
  49. if (validate_message)
  50. {
  51. mTemplateMessageReader.readMessage(&(data[0]),host);
  52. }
  53. else
  54. {
  55. gMessageSystem->clearReceiveState();
  56. }
  57. }