forked from LosaDev/ls-2019-source
LosaDev source snapshot 2019
This commit is contained in:
commit
c198676e97
20588 files changed
+8812878
No files matched your search
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include "cBuffer.h"
|
||||
#include "../common/Protocol.h"
|
||||
#include "../include/BoostPooler.h"
|
||||
|
||||
class IIocpContext;
|
||||
|
||||
// 技记鸥涝
|
||||
enum SessionTypes
|
||||
{
|
||||
SESSION_NORMAL = 0,
|
||||
SESSION_LOGIN,
|
||||
SESSION_PLAYER,
|
||||
SESSION_SERVER,
|
||||
SESSION_OPERATOR,
|
||||
};
|
||||
|
||||
// 技记牢磐其捞胶
|
||||
class ISession
|
||||
{
|
||||
public:
|
||||
ISession(void) : m_sessionType(SESSION_NORMAL), m_context(NULL)
|
||||
{}
|
||||
|
||||
public:
|
||||
void SetType(const SessionTypes type) { m_sessionType = type; }
|
||||
void SetContext(IIocpContext* context) { m_context = context; }
|
||||
|
||||
SessionTypes GetType() { return m_sessionType; }
|
||||
IIocpContext* GetContext() { return m_context; }
|
||||
|
||||
public:
|
||||
BOOL IsNormal() { return (SESSION_NORMAL == m_sessionType) ? TRUE : FALSE; }
|
||||
BOOL IsWaiter() { return (SESSION_LOGIN == m_sessionType) ? TRUE : FALSE; }
|
||||
BOOL IsPlayer() { return (SESSION_PLAYER == m_sessionType) ? TRUE : FALSE; }
|
||||
BOOL IsServer() { return (SESSION_SERVER == m_sessionType) ? TRUE : FALSE; }
|
||||
|
||||
public:
|
||||
virtual void OnConnect() {};
|
||||
virtual void OnDisconnect() {};
|
||||
|
||||
protected:
|
||||
SessionTypes m_sessionType;
|
||||
IIocpContext* m_context;
|
||||
};
|
||||
|
||||
// 扁夯技记
|
||||
class cSession : public ISession, public BoostPooler<cSession>
|
||||
{
|
||||
public:
|
||||
cSession(void) {}
|
||||
|
||||
public:
|
||||
virtual void OnConnect();
|
||||
virtual void OnDisconnect();
|
||||
|
||||
public:
|
||||
BOOL TransferBegin(const TCHAR* file, const uint32 length);
|
||||
BOOL TransferDo(const uint8* buffer, const uint32 length);
|
||||
void TransferWrite();
|
||||
void TransferEnd();
|
||||
BOOL DoingTransfer() { return m_transfer; }
|
||||
|
||||
const TCHAR* GetFile() { return m_file; }
|
||||
const uint8* GetBuffer() { return m_buffer.GetBuffer(); }
|
||||
const uint32 GetLength() { return m_buffer.GetLength(); }
|
||||
const uint32 GetTransferLength() { return m_transferLength; }
|
||||
|
||||
public:
|
||||
BOOL m_transfer;
|
||||
TCHAR m_file[512];
|
||||
uint32 m_transferLength;
|
||||
cBuffer m_buffer;
|
||||
};
|
||||
Reference in new issue
Block a user