PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms 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
  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
 27#ifndef LL_LLPACKETACK_H
 28#define LL_LLPACKETACK_H
 29
 30#include "llhost.h"
 31
 32class LLReliablePacketParams
 33{
 34public:
 35	LLHost mHost;
 36	S32 mRetries;
 37	BOOL mPingBasedRetry;
 38	F32 mTimeout;
 39	void (*mCallback)(void **,S32);
 40	void** mCallbackData;
 41	char* mMessageName;
 42
 43public:
 44	LLReliablePacketParams()
 45	{
 46		clear();
 47	};
 48
 49	~LLReliablePacketParams() { };
 50
 51	void clear()
 52	{
 53		mHost.invalidate();
 54		mRetries = 0;
 55		mPingBasedRetry = TRUE;
 56		mTimeout = 0.f;
 57		mCallback = NULL;
 58		mCallbackData = NULL;
 59		mMessageName = NULL;
 60	};
 61
 62	void set(
 63		const LLHost& host,
 64		S32 retries,
 65		BOOL ping_based_retry,
 66		F32 timeout, 
 67		void (*callback)(void**,S32),
 68		void** callback_data, char* name)
 69	{
 70		mHost = host;
 71		mRetries = retries;
 72		mPingBasedRetry = ping_based_retry;
 73		mTimeout = timeout;
 74		mCallback = callback;
 75		mCallbackData = callback_data;
 76		mMessageName = name;
 77	};
 78};
 79
 80class LLReliablePacket
 81{
 82public:
 83	LLReliablePacket(
 84		S32 socket,
 85		U8* buf_ptr,
 86		S32 buf_len,
 87		LLReliablePacketParams* params);
 88	~LLReliablePacket()
 89	{ 
 90		mCallback = NULL;
 91		delete [] mBuffer;
 92		mBuffer = NULL;
 93	};
 94
 95	friend class LLCircuitData;
 96protected:
 97	S32 mSocket;
 98	LLHost mHost;
 99	S32 mRetries;
100	BOOL mPingBasedRetry;
101	F32 mTimeout;
102	void (*mCallback)(void**,S32);
103	void** mCallbackData;
104	char* mMessageName;
105
106	U8* mBuffer;
107	S32 mBufferLength;
108
109	TPACKETID mPacketID;
110
111	F64 mExpirationTime;
112};
113
114#endif
115