DragonNest/Server/ServerCommon/SimpleClientSession.h
2024-12-20 16:56:44 +08:00

48 lines
No EOL
1.9 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.


#pragma once
#include <winsock.h>
#include "multisync.h"
const int RECVBUFFERSIZEMAX = 1024 * 10;
const int SENDBUFFERDIZEMAX = 1024 * 10;
class CBuffer;
class CSimpleClientSession
{
public :
CSimpleClientSession();
virtual ~CSimpleClientSession();
bool Start(const TCHAR *ip, int port);
void Stop() { m_bTerminate = true; }
int SendPacket(int header, const void *data, int size);
protected :
virtual bool AddPacket(const DNTPacket * packet) = 0;
virtual void Connect() {}
virtual void Destroy();
virtual void TimeEvent() = 0;
bool m_bTerminate;
private :
void ReceiveMessage(int totalbytes);
char m_pBuff[RECVBUFFERSIZEMAX];
int m_iLen;
char m_pSendBuff[SENDBUFFERDIZEMAX];
CBuffer* m_pSendQueue;
CSyncLock m_SendSync; //sendbuffer sync
HANDLE m_hSendThread;
void _FlushSendData();
SOCKET m_hLobbySocket;
static SOCKET CreateTCPSocket(int port);
static UINT __stdcall SendThread(void *pParam);
} ;