ScummVM API documentation
host.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_NETWORKING_ENET_HOST_H
23#define BACKENDS_NETWORKING_ENET_HOST_H
24
25typedef struct _ENetHost ENetHost;
26typedef struct _ENetPeer ENetPeer;
27
28typedef struct _ENetEvent ENetEvent;
29typedef struct _ENetPacket ENetPacket;
30
31
32// Event types
33#define ENET_EVENT_TYPE_NONE 0
34#define ENET_EVENT_TYPE_CONNECT 1
35#define ENET_EVENT_TYPE_DISCONNECT 2
36#define ENET_EVENT_TYPE_RECEIVE 3
37
38#include "common/system.h"
39#include "common/str.h"
40#include "common/debug.h"
41
42namespace Networking {
43namespace ENet {
44
45class Host {
46public:
52 Host(ENetHost *host);
59 Host(ENetHost *host, ENetPeer *serverPeer);
60 ~Host();
61
70 uint8 service(int timeout = 0);
71
81 bool connectPeer(const Common::String &address, int port, int timeout = 5000, int numChannels = 1);
87 void disconnectPeer(int peerIndex);
88
99 bool send(const char *data, int peerIndex, int channel = 0, bool reliable = true);
110 bool sendRawData(const Common::String &address, int port, const char *data);
111
123 int getPort();
124
132 int getPeerIndexFromHost(const Common::String &host, int port);
133
144private:
145
151 ENetHost *_host;
156 ENetPeer *_serverPeer;
161 Common::String _recentHost;
166 int _recentPort;
171 ENetPacket *_recentPacket;
172};
173
174} // End of namespace ENet
175} // End of namespace Networking
176
177#endif
Definition: str.h:59
Definition: host.h:45
Host(ENetHost *host)
void disconnectPeer(int peerIndex)
Common::String getPacketData()
uint8 service(int timeout=0)
bool sendRawData(const Common::String &address, int port, const char *data)
Host(ENetHost *host, ENetPeer *serverPeer)
bool send(const char *data, int peerIndex, int channel=0, bool reliable=true)
bool connectPeer(const Common::String &address, int port, int timeout=5000, int numChannels=1)
int getPeerIndexFromHost(const Common::String &host, int port)
Common::String getHost()
Definition: enet.h:440
Definition: enet.h:364
Definition: enet.h:149
Definition: enet.h:264