diff options
| author | 2017-07-07 21:34:15 +0200 | |
|---|---|---|
| committer | 2017-07-07 15:34:15 -0400 | |
| commit | 2e37ce01c9dcdc5932cf5fe47a1ade0e0d2b7cf8 (patch) | |
| tree | b5298b3c528d9acc1f3fa48f19c9f9c19c97d036 /src/network/room_member.h | |
| parent | Merge pull request #2814 from Kloen/macro-remove (diff) | |
| download | yuzu-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_member.h')
| -rw-r--r-- | src/network/room_member.h | 65 |
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 | |||
| 13 | namespace 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 | */ | ||
| 20 | class RoomMember final { | ||
| 21 | public: | ||
| 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 | |||
| 60 | private: | ||
| 61 | class RoomMemberImpl; | ||
| 62 | std::unique_ptr<RoomMemberImpl> room_member_impl; | ||
| 63 | }; | ||
| 64 | |||
| 65 | } // namespace Network | ||