📄 smscsocket.h
字号:
#if !defined(AFX_SMSCSOCKET_H__92C161F6_5D5F_41F4_AF6D_ECA4035C9CFC__INCLUDED_)
#define AFX_SMSCSOCKET_H__92C161F6_5D5F_41F4_AF6D_ECA4035C9CFC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SMSCSocket.h : header file
//
#include <afxtempl.h>
class CSMPProtocol;
class CAmuseCom;
#define NOCONNECT 0
#define CONNECTED 1
//============================================================
//Modify by LiuTianJun at 2001-12-22
#define CONNECT_TIMEOUT_SEC 6
//============================================================
#define MAX_SOCKETMSG_BUFF 10240
#define MAX_PACKAGE_LEN 400
#define APP_SMPPROTOCOL 1
#define APP_AMUSECOM 2
/////////////////////////////////////////////////////////////////////////////
// CSMSCSocket command target
//自封装SOCKET类,可以实现连接,发送,接收和阻塞处理;
class CSMSCSocket : public CAsyncSocket
{
//成员变量--公有
public:
//成员函数--公有
public:
CSMSCSocket(int nAppID,void* pVoid);
virtual ~CSMSCSocket();
int SMSConnect(char* szDestIP,int nDestPort);
int SMSCDisConnect();
int SMSCSendMsg(char* szSendMsg,long nMsgLength);
int SMSCGetStatus();
//成员变量--私有
private:
int m_nStatus; //连接状态:NOCONNECT为未连接,CONNECT为已连接
int m_nBlock; //阻塞标志:0为未阻塞,1为发生阴塞;
int m_nRecvMsgBuffLen; //接收缓存区中的数据长度;
char m_szRecvMsgBuff[MAX_SOCKETMSG_BUFF+1]; //接收缓存区;
CSMPProtocol* m_pcSMPProtocol; //SMPP协议层实例指针;
CAmuseCom* m_pcAmuseCom; //游戏引擎实例指针;
int m_nAppID; //应用号:指明此SOCKET用于何应用,APP_SMPPROTOCOL为SMPP协议层;
//,APP_AMUSECOM 为游戏引擎层;
struct struSENDPACKAGE{
char szMsg[MAX_PACKAGE_LEN];
int nMsgLen;
};
CList<struSENDPACKAGE,struSENDPACKAGE> m_listSendMsgBuff;
//发送失败缓存列表(当发生阻塞时写入此列表);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSMSCSocket)
protected:
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual void OnConnect(int nErrorCode);
virtual void OnClose(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CSMSCSocket)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
private:
int Print(char* szPrintMsg); //显示信息函数;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SMSCSOCKET_H__92C161F6_5D5F_41F4_AF6D_ECA4035C9CFC__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -