Rev 984 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 984 | Rev 1024 | ||
|---|---|---|---|
| 1 | /*************************************************************************** |
1 | /*************************************************************************** |
| 2 | * Copyright (C) December 30, 2008 by Mattias Runge * |
2 | * Copyright (C) December 30, 2008 by Mattias Runge * |
| 3 | * mattias@runge.se * |
3 | * mattias@runge.se * |
| 4 | * socketevent.h * |
4 | * socketevent.h * |
| 5 | * * |
5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
9 | * (at your option) any later version. * |
| 10 | * * |
10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
14 | * GNU General Public License for more details. * |
| 15 | * * |
15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the * |
17 | * along with this program; if not, write to the * |
| 18 | * Free Software Foundation, Inc., * |
18 | * Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
20 | ***************************************************************************/ |
| 21 | 21 | ||
| 22 | #ifndef _SOCKETEVENT_H |
22 | #ifndef _SOCKETEVENT_H |
| 23 | #define _SOCKETEVENT_H |
23 | #define _SOCKETEVENT_H |
| 24 | 24 | ||
| 25 | using namespace std; |
25 | using namespace std; |
| 26 | 26 | ||
| 27 | #include <string> |
27 | #include <string> |
| 28 | - | ||
| 29 | #define ASYNCSOCKET_EVENT_NONE 0 |
- | |
| 30 | #define ASYNCSOCKET_EVENT_DATA 1 |
- | |
| 31 | #define ASYNCSOCKET_EVENT_CONNECTED 2 |
- | |
| 32 | #define ASYNCSOCKET_EVENT_CONNECT_FAILED 3 |
- | |
| 33 | #define ASYNCSOCKET_EVENT_WAITING_TO_RECONNECT 4 |
- | |
| 34 | #define ASYNCSOCKET_EVENT_CLOSED 5 |
- | |
| 35 | #define ASYNCSOCKET_EVENT_RESET 6 |
- | |
| 36 | #define ASYNCSOCKET_EVENT_DIED 7 |
- | |
| 37 | #define ASYNCSOCKET_EVENT_INACTIVITY 8 |
- | |
| 38 | 28 | ||
| 39 | class SocketEvent |
29 | class SocketEvent |
| 40 | { |
30 | { |
| 41 | public: |
31 | public: |
| 42 | SocketEvent(unsigned int type, string data) |
32 | SocketEvent(unsigned int type, string data) |
| 43 | { |
33 | { |
| 44 | myType = type; |
34 | myType = type; |
| 45 | myData = data; |
35 | myData = data; |
| 46 | } |
36 | } |
| 47 | 37 | ||
| 48 | SocketEvent(const SocketEvent& socketEvent) |
38 | SocketEvent(const SocketEvent& socketEvent) |
| 49 | { |
39 | { |
| 50 | myType = socketEvent.myType; |
40 | myType = socketEvent.myType; |
| 51 | myData = socketEvent.myData; |
41 | myData = socketEvent.myData; |
| 52 | } |
42 | } |
| 53 | 43 | ||
| 54 | unsigned int getType() { return myType; }; |
44 | unsigned int getType() { return myType; }; |
| 55 | string getData() { return myData; }; |
45 | string getData() { return myData; }; |
| 56 | 46 | ||
| 57 | static const unsigned int TYPE_NONE = 0; |
47 | static const unsigned int TYPE_NONE = 0; |
| 58 | static const unsigned int TYPE_DATA = 1; |
48 | static const unsigned int TYPE_DATA = 1; |
| 59 | static const unsigned int TYPE_INACTIVITY = 2; |
49 | static const unsigned int TYPE_INACTIVITY = 2; |
| 60 | 50 | ||
| 61 | static const unsigned int TYPE_CONNECTING = 3; |
51 | static const unsigned int TYPE_CONNECTING = 3; |
| 62 | static const unsigned int TYPE_CONNECTED = 4; |
52 | static const unsigned int TYPE_CONNECTED = 4; |
| 63 | static const unsigned int TYPE_WAITING_RECONNECT = 5; |
53 | static const unsigned int TYPE_WAITING_RECONNECT = 5; |
| 64 | static const unsigned int TYPE_CONNECTION_CLOSED = 6; |
54 | static const unsigned int TYPE_CONNECTION_CLOSED = 6; |
| 65 | static const unsigned int TYPE_CONNECTION_RESET = 7; |
55 | static const unsigned int TYPE_CONNECTION_RESET = 7; |
| 66 | static const unsigned int TYPE_CONNECTION_DIED = 8; |
56 | static const unsigned int TYPE_CONNECTION_DIED = 8; |
| 67 | static const unsigned int TYPE_CONNECTION_FAILED = 9; |
57 | static const unsigned int TYPE_CONNECTION_FAILED = 9; |
| 68 | 58 | ||
| 69 | private: |
59 | private: |
| 70 | unsigned int myType; |
60 | unsigned int myType; |
| 71 | string myData; |
61 | string myData; |
| 72 | }; |
62 | }; |
| 73 | 63 | ||
| 74 | #endif /* _SOCKETEVENT_H */ |
64 | #endif /* _SOCKETEVENT_H */ |
| 75 | 65 | ||
| 76 | 66 | ||