-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcp.hpp
54 lines (43 loc) · 1019 Bytes
/
tcp.hpp
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
#ifndef TCP_HPP
#define TCP_HPP
#include <wx/wx.h>
#include <wx/sckipc.h>
#include <vector>
using namespace std;
class TCPServer;
class TCPConnection;
class ConnecTimer;
class TCPServer : public wxTCPServer
{
friend class ConnecTimer;
friend class TCPConnection;
public:
~TCPServer();
wxConnectionBase* OnAcceptConnection(const wxString& topic);
size_t IDManager();
private:
vector<TCPConnection*> conns;
};
class TCPConnection : public wxTCPConnection
{
friend class TCPServer;
public:
TCPConnection(TCPServer* _server, wxString _nick);
bool OnDisconnect();
bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
char* OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format);
private:
size_t id;
wxString nick;
TCPServer* server;
};
class ConnecTimer : public wxTimer
{
public:
void Notify();
ConnecTimer(TCPServer* _serv, wxString _nick);
private:
wxString nick;
TCPServer* serv;
};
#endif