summaryrefslogtreecommitdiff
path: root/src/network/room.h
diff options
context:
space:
mode:
authorGravatar B3n302017-07-07 21:34:15 +0200
committerGravatar bunnei2017-07-07 15:34:15 -0400
commit2e37ce01c9dcdc5932cf5fe47a1ade0e0d2b7cf8 (patch)
treeb5298b3c528d9acc1f3fa48f19c9f9c19c97d036 /src/network/room.h
parentMerge pull request #2814 from Kloen/macro-remove (diff)
downloadyuzu-2e37ce01c9dcdc5932cf5fe47a1ade0e0d2b7cf8.tar.gz
yuzu-2e37ce01c9dcdc5932cf5fe47a1ade0e0d2b7cf8.tar.xz
yuzu-2e37ce01c9dcdc5932cf5fe47a1ade0e0d2b7cf8.zip
Implement basic virtual Room support based on enet (#2803)
* Added support for network with ENet lib, connecting is possible, but data can't be sent, yet. * fixup! Added support for network with ENet lib, * fixup! CLang * fixup! Added support for network with ENet lib, * fixup! Added support for network with ENet lib, * fixup! Clang format * More fixups! * Moved ENetHost* and ENetPeer* into pimpl classes * fixup! Moved ENetHost* and ENetPeer* into pimpl classes * fixup! Clang again * fixup! Moved ENetHost* and ENetPeer* into pimpl classes * fixup! Moved ENetHost* and ENetPeer* into pimpl classes * fixup! Moved ENetHost* and ENetPeer* into pimpl classes
Diffstat (limited to 'src/network/room.h')
-rw-r--r--src/network/room.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/network/room.h b/src/network/room.h
new file mode 100644
index 000000000..70c64d5f1
--- /dev/null
+++ b/src/network/room.h
@@ -0,0 +1,60 @@
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
12namespace Network {
13
14constexpr u16 DefaultRoomPort = 1234;
15constexpr size_t NumChannels = 1; // Number of channels used for the connection
16
17struct RoomInformation {
18 std::string name; ///< Name of the server
19 u32 member_slots; ///< Maximum number of members in this room
20};
21
22/// This is what a server [person creating a server] would use.
23class Room final {
24public:
25 enum class State : u8 {
26 Open, ///< The room is open and ready to accept connections.
27 Closed, ///< The room is not opened and can not accept connections.
28 };
29
30 Room();
31 ~Room();
32
33 /**
34 * Gets the current state of the room.
35 */
36 State GetState() const;
37
38 /**
39 * Gets the room information of the room.
40 */
41 const RoomInformation& GetRoomInformation() const;
42
43 /**
44 * Creates the socket for this room. Will bind to default address if
45 * server is empty string.
46 */
47 void Create(const std::string& name, const std::string& server = "",
48 u16 server_port = DefaultRoomPort);
49
50 /**
51 * Destroys the socket
52 */
53 void Destroy();
54
55private:
56 class RoomImpl;
57 std::unique_ptr<RoomImpl> room_impl;
58};
59
60} // namespace Network