summaryrefslogtreecommitdiff
path: root/src/network/room.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/room.h')
-rw-r--r--src/network/room.h101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/network/room.h b/src/network/room.h
deleted file mode 100644
index 8285a4d0c..000000000
--- a/src/network/room.h
+++ /dev/null
@@ -1,101 +0,0 @@
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 <array>
8#include <memory>
9#include <string>
10#include <vector>
11#include "common/common_types.h"
12
13namespace Network {
14
15constexpr u32 network_version = 1; ///< The version of this Room and RoomMember
16
17constexpr u16 DefaultRoomPort = 1234;
18constexpr size_t NumChannels = 1; // Number of channels used for the connection
19
20struct RoomInformation {
21 std::string name; ///< Name of the server
22 u32 member_slots; ///< Maximum number of members in this room
23};
24
25struct GameInfo {
26 std::string name{""};
27 u64 id{0};
28};
29
30using MacAddress = std::array<u8, 6>;
31/// A special MAC address that tells the room we're joining to assign us a MAC address
32/// automatically.
33constexpr MacAddress NoPreferredMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
34
35// 802.11 broadcast MAC address
36constexpr MacAddress BroadcastMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
37
38// The different types of messages that can be sent. The first byte of each packet defines the type
39enum RoomMessageTypes : u8 {
40 IdJoinRequest = 1,
41 IdJoinSuccess,
42 IdRoomInformation,
43 IdSetGameInfo,
44 IdWifiPacket,
45 IdChatMessage,
46 IdNameCollision,
47 IdMacCollision,
48 IdVersionMismatch,
49 IdCloseRoom
50};
51
52/// This is what a server [person creating a server] would use.
53class Room final {
54public:
55 enum class State : u8 {
56 Open, ///< The room is open and ready to accept connections.
57 Closed, ///< The room is not opened and can not accept connections.
58 };
59
60 struct Member {
61 std::string nickname; ///< The nickname of the member.
62 GameInfo game_info; ///< The current game of the member
63 MacAddress mac_address; ///< The assigned mac address of the member.
64 };
65
66 Room();
67 ~Room();
68
69 /**
70 * Gets the current state of the room.
71 */
72 State GetState() const;
73
74 /**
75 * Gets the room information of the room.
76 */
77 const RoomInformation& GetRoomInformation() const;
78
79 /**
80 * Gets a list of the mbmers connected to the room.
81 */
82 std::vector<Member> GetRoomMemberList() const;
83
84 /**
85 * Creates the socket for this room. Will bind to default address if
86 * server is empty string.
87 */
88 void Create(const std::string& name, const std::string& server = "",
89 u16 server_port = DefaultRoomPort);
90
91 /**
92 * Destroys the socket
93 */
94 void Destroy();
95
96private:
97 class RoomImpl;
98 std::unique_ptr<RoomImpl> room_impl;
99};
100
101} // namespace Network