PageRenderTime 37ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/llpacketack.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 115 lines | 76 code | 14 blank | 25 comment | 0 complexity | b8f694254b1c5bdc7b2724f5ebe885f3 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpacketack.h
  3. * @brief Reliable UDP helpers for the message system.
  4. *
  5. * $LicenseInfo:firstyear=2001&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. #ifndef LL_LLPACKETACK_H
  27. #define LL_LLPACKETACK_H
  28. #include "llhost.h"
  29. class LLReliablePacketParams
  30. {
  31. public:
  32. LLHost mHost;
  33. S32 mRetries;
  34. BOOL mPingBasedRetry;
  35. F32 mTimeout;
  36. void (*mCallback)(void **,S32);
  37. void** mCallbackData;
  38. char* mMessageName;
  39. public:
  40. LLReliablePacketParams()
  41. {
  42. clear();
  43. };
  44. ~LLReliablePacketParams() { };
  45. void clear()
  46. {
  47. mHost.invalidate();
  48. mRetries = 0;
  49. mPingBasedRetry = TRUE;
  50. mTimeout = 0.f;
  51. mCallback = NULL;
  52. mCallbackData = NULL;
  53. mMessageName = NULL;
  54. };
  55. void set(
  56. const LLHost& host,
  57. S32 retries,
  58. BOOL ping_based_retry,
  59. F32 timeout,
  60. void (*callback)(void**,S32),
  61. void** callback_data, char* name)
  62. {
  63. mHost = host;
  64. mRetries = retries;
  65. mPingBasedRetry = ping_based_retry;
  66. mTimeout = timeout;
  67. mCallback = callback;
  68. mCallbackData = callback_data;
  69. mMessageName = name;
  70. };
  71. };
  72. class LLReliablePacket
  73. {
  74. public:
  75. LLReliablePacket(
  76. S32 socket,
  77. U8* buf_ptr,
  78. S32 buf_len,
  79. LLReliablePacketParams* params);
  80. ~LLReliablePacket()
  81. {
  82. mCallback = NULL;
  83. delete [] mBuffer;
  84. mBuffer = NULL;
  85. };
  86. friend class LLCircuitData;
  87. protected:
  88. S32 mSocket;
  89. LLHost mHost;
  90. S32 mRetries;
  91. BOOL mPingBasedRetry;
  92. F32 mTimeout;
  93. void (*mCallback)(void**,S32);
  94. void** mCallbackData;
  95. char* mMessageName;
  96. U8* mBuffer;
  97. S32 mBufferLength;
  98. TPACKETID mPacketID;
  99. F64 mExpirationTime;
  100. };
  101. #endif