⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdmanager.h

📁 五行MMORPG引擎系统V1.0
💻 H
字号:
// Command.h: interface for the CmdManager class.
/*/////////////////////////////////////////////////////////////////////////////

	李亦
	2006.06.
/*//////////////////////////////////////////////////////////////////////////////


#if !defined(_CMDMANAGER_H_)
#define _CMDMANAGER_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef _AUTHSOCKET_H_
#include "server/net/AuthSocket.h"
#endif

namespace CS
{

class CmdManager;
typedef int (*CS_CMDCALLBACK)(CmdManager *pCommand,CAuthSocket *cas_from, int comid, DWORD nArg1, char *svArg2, char *svArg3);



///////////////////////////////////////////////////////////////////////////////
//指令定义
enum CmdConstant
{
	CS_CMD_SIMPLE	= 0,
	CS_CMD_PING,
	CS_CMD_QUERY,


	CSCMD_NATIVE_MAX		= 200,
	CS_COMMAND_USER		= 1000,
	CS_COMMAND_DATA,

	CS_CMD_AMOUNT			= 1024
};


#define CMDFLAG_COMMAND			1
#define CMDFLAG_REPLY			2
#define INVALID_CMDCALLBACK	((CS_CMDCALLBACK) NULL)




///////////////////////////////////////////////////////////////////////////////
//指令管理封装
class CmdManager  
{
#pragma pack(push,1)
	typedef struct 
	{
		BOOL bNative;
		char *svFolderName;
		char *svCommName;
		char *svArgDesc1;
		char *svArgDesc2;
		char *svArgDesc3;
	} CS_CMD_DESC; 
#pragma pack(pop)

	typedef struct  
	{
		int	cmdlen;
		char	flags;
		int	command;
		int	comid;
		int	nArg1;
		int	nArg2Len;
		int	nArg3Len;
	}CMD_HEADER;

	HANDLE m_hDispatchMutex;

public:
	CS_CMDCALLBACK *m_pCmdCallbacks;
	CS_CMD_DESC		*m_pCmdDescs;


public:
	int DispatchCommand			(int command, CAuthSocket *cas_from, int comid, int nArg1, char *svArg2, char *svArg3);
	int UnregisterCommand		(int command);
	int RegisterCommand			(CS_CMDCALLBACK handler, char *svFolderName, char *svCommName, char *svArgDesc1, char *svArgDesc2, char *svArgDesc3);
	int RegisterNativeCommands			();
	int RegisterNativeCommand			(int command, CS_CMDCALLBACK handler);
	int KillCommandDispatcher			(void);
	int InitializeCommandDispatcher	(void);
	
	
	int IssueAuthCommandReply	(CAuthSocket *cas_from, int comid, int nReplyCode, char *svReply);
	int IssueAuthCommandRequest(CAuthSocket *cas_from, int command, int comid, int nArg1, char *svArg2, char *svArg3);
	void FreeCommandMemory		(BYTE *pCmd);
	BYTE* BuildCommandReply		(int comid, int nReplyCode, char *svReply, int *pnReqLen);
	BYTE* BuildCommandRequest	(int command, int comid, int nArg1, char *svArg2, char *svArg3, int *pnReqLen);
	UINT	BreakDownCommand		(BYTE *pInBuffer, int *cmdlen, int *command, int *comid, int *nArg1, char **svArg2, char **svArg3);
	
public:
	CmdManager();
	virtual ~CmdManager();

};

};//namespace CS


#endif // !defined(_CMDMANAGER_H_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -