2007-11-16 15:24:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2007 by Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
/* Network sender thread. */
|
|
|
|
|
|
2009-05-10 22:21:20 +00:00
|
|
|
#ifndef _SENDERHELPER_H_
|
|
|
|
|
#define _SENDERHELPER_H_
|
2007-11-16 15:24:25 +00:00
|
|
|
|
|
|
|
|
#include <net/netpacket.h>
|
|
|
|
|
#include <net/sendercallback.h>
|
|
|
|
|
|
2009-01-11 20:12:26 +00:00
|
|
|
class SessionData;
|
2009-01-31 21:03:34 +00:00
|
|
|
class SendDataManager;
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-06-07 08:51:43 +00:00
|
|
|
class SenderHelper
|
2007-11-16 15:24:25 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2009-05-10 22:21:20 +00:00
|
|
|
SenderHelper(SenderCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
2009-06-07 08:51:43 +00:00
|
|
|
~SenderHelper();
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-06-07 08:51:43 +00:00
|
|
|
void Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
|
|
|
|
|
void Send(boost::shared_ptr<SessionData> session, const NetPacketList &packetList);
|
2007-11-16 15:24:25 +00:00
|
|
|
|
2009-06-07 08:51:43 +00:00
|
|
|
void SignalSessionTerminated(unsigned sessionId);
|
2009-01-26 20:57:39 +00:00
|
|
|
|
2007-11-16 15:24:25 +00:00
|
|
|
protected:
|
2009-08-02 15:11:40 +00:00
|
|
|
void InternalStorePacket(SendDataManager &tmpManager, boost::shared_ptr<NetPacket> packet);
|
|
|
|
|
|
2009-01-25 20:19:09 +00:00
|
|
|
typedef std::map<SessionId, boost::shared_ptr<SendDataManager> > SendQueueMap;
|
|
|
|
|
|
2007-11-16 15:24:25 +00:00
|
|
|
private:
|
|
|
|
|
|
2009-02-27 22:41:16 +00:00
|
|
|
SenderCallback &m_callback;
|
|
|
|
|
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
|
|
|
|
|
2009-01-25 20:19:09 +00:00
|
|
|
SendQueueMap m_sendQueueMap;
|
|
|
|
|
mutable boost::mutex m_sendQueueMapMutex;
|
2007-11-16 15:24:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|