Mana
Loading...
Searching...
No Matches
connection.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <enet/enet.h>
26
27namespace ManaServ
28{
29 class MessageOut;
30
35 {
36 public:
37 enum State {
40 };
41
43
49 bool connect(const std::string &address, enet_uint16 port);
50
54 void disconnect();
55
56 State getState() { return mState; }
57
61 bool isConnected();
62
66 void send(const ManaServ::MessageOut &msg);
67
68 private:
70 Connection(ENetHost *client);
71
72 short mPort = 0;
73 ENetPeer *mConnection = nullptr;
74 ENetHost *mClient;
76 };
77}
bool isConnected()
Returns whether the server is connected.
void send(const ManaServ::MessageOut &msg)
Sends a message.
bool connect(const std::string &address, enet_uint16 port)
Connects to the given server with the specified address and port.
ENetPeer * mConnection
Definition connection.h:73
void disconnect()
Disconnects from the given server.
Used for building an outgoing message to manaserv.
Definition messageout.h:37
Connection * getConnection()
Returns a new Connection object.
Definition network.cpp:77