summaryrefslogtreecommitdiff
path: root/src/network/room_member.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/room_member.h')
-rw-r--r--src/network/room_member.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/network/room_member.h b/src/network/room_member.h
new file mode 100644
index 000000000..177622b69
--- /dev/null
+++ b/src/network/room_member.h
@@ -0,0 +1,65 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <atomic>
8#include <memory>
9#include <string>
10#include "common/common_types.h"
11#include "network/room.h"
12
13namespace Network {
14
15/**
16 * This is what a client [person joining a server] would use.
17 * It also has to be used if you host a game yourself (You'd create both, a Room and a
18 * RoomMembership for yourself)
19 */
20class RoomMember final {
21public:
22 enum class State : u8 {
23 Idle, ///< Default state
24 Error, ///< Some error [permissions to network device missing or something]
25 Joining, ///< The client is attempting to join a room.
26 Joined, ///< The client is connected to the room and is ready to send/receive packets.
27 LostConnection, ///< Connection closed
28
29 // Reasons why connection was rejected
30 NameCollision, ///< Somebody is already using this name
31 MacCollision, ///< Somebody is already using that mac-address
32 CouldNotConnect ///< The room is not responding to a connection attempt
33 };
34
35 RoomMember();
36 ~RoomMember();
37
38 /**
39 * Returns the status of our connection to the room.
40 */
41 State GetState() const;
42
43 /**
44 * Returns whether we're connected to a server or not.
45 */
46 bool IsConnected() const;
47
48 /**
49 * Attempts to join a room at the specified address and port, using the specified nickname.
50 * This may fail if the username is already taken.
51 */
52 void Join(const std::string& nickname, const char* server_addr = "127.0.0.1",
53 const u16 serverPort = DefaultRoomPort, const u16 clientPort = 0);
54
55 /**
56 * Leaves the current room.
57 */
58 void Leave();
59
60private:
61 class RoomMemberImpl;
62 std::unique_ptr<RoomMemberImpl> room_member_impl;
63};
64
65} // namespace Network