-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiclient.h
56 lines (44 loc) · 1.4 KB
/
iclient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _D_ICLIENT_H_
#define _D_ICLIENT_H_
#include "isocket.h"
class ITcpClientDataHandle
{
public:
virtual ~ITcpClientDataHandle(){}
public:
virtual void OnConnected(SocketClientData_t sClient) = 0;
virtual void OnDisconnected(SocketClientData_t sClient, int nErrorCode) = 0;
virtual void OnDataReceived(SocketClientData_t sClient, const char * pData, int nLen) = 0;
virtual void OnSendError(SocketClientData_t sClient, int nErrorCode) = 0;
virtual void OnRecvError(SocketClientData_t sClient, int nErrorCode) = 0;
};
class IUdpClientDataHandle
{
public:
virtual ~IUdpClientDataHandle(){}
public:
virtual void OnDataReceived(unsigned int IP, unsigned short Port, const char * pData, int nLen) = 0;
};
class ITcpClient
{
public:
virtual ~ITcpClient(){}
public:
virtual void SetDataHandle(ITcpClientDataHandle * pDataHandle) = 0;
virtual bool Start(unsigned int IP, unsigned short Port) = 0;
virtual bool Stop() = 0;
virtual bool Send(const char *pData, int nDataLen) = 0;
};
class IUdpClient
{
public:
virtual ~IUdpClient(){}
public:
virtual void SetDataHandle(IUdpClientDataHandle * pDataHandle) = 0;
virtual bool Start(unsigned int IP, unsigned short Port) = 0;
virtual bool Stop() = 0;
virtual void Send(const char * pData, int nDataLen) = 0;
};
ITcpClient * CreateTcpClientInstance();
IUdpClient * CreateUdpClientInstance();
#endif