diff options
| author | Aleksandr Popovich <alekpopo@pm.me> | 2025-06-05 18:59:47 +0000 |
|---|---|---|
| committer | crueter <crueter@noreply.localhost> | 2025-06-05 18:59:47 +0000 |
| commit | 76fa5255926da8f6339e7be5bf106646acedf78a (patch) | |
| tree | 8ea533a7d748a9a5404e15a1063b11a832b2f007 /src/common/android/multiplayer/multiplayer.h | |
| parent | 7e13da47af71814d612c6c060be68e8ba84271ff (diff) | |
Added the public lobby to android. (#125)
This is adapted from kleidis old PR to Azahar. Changes from it:
- Fixed inconsistent button styling in the dialog for connection
- Allowed to hide both empty and full rooms.
- Proper serving of preferred games
- Enables web service for android by default
- Better implementation of multiplayer.cpp that works with oop
Also fixes the room network class and turns it into a static namespace
in network
Signed-off-by: Aleksandr Popovich <alekpopo@pm.me>
Co-authored-by: swurl <swurl@swurl.xyz>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/125
Co-authored-by: Aleksandr Popovich <alekpopo@pm.me>
Co-committed-by: Aleksandr Popovich <alekpopo@pm.me>
Diffstat (limited to 'src/common/android/multiplayer/multiplayer.h')
| -rw-r--r-- | src/common/android/multiplayer/multiplayer.h | 80 |
1 files changed, 57 insertions, 23 deletions
diff --git a/src/common/android/multiplayer/multiplayer.h b/src/common/android/multiplayer/multiplayer.h index 4f32c514e0..591d3be8fd 100644 --- a/src/common/android/multiplayer/multiplayer.h +++ b/src/common/android/multiplayer/multiplayer.h @@ -1,8 +1,4 @@ -// Copyright 2024 Mandarine Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -// SPDX-FileCopyrightText: Copyright yuzu/Citra Emulator Project / Eden Emulator Project +// SPDX-FileCopyrightText: 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #pragma once @@ -12,6 +8,12 @@ #include <common/common_types.h> #include <network/network.h> +#include <network/announce_multiplayer_session.h> + +namespace Core { + class System; + class AnnounceMultiplayerSession; +} enum class NetPlayStatus : s32 { NO_ERROR, @@ -48,21 +50,53 @@ enum class NetPlayStatus : s32 { CHAT_MESSAGE, }; -bool NetworkInit(Network::RoomNetwork* room_network); -NetPlayStatus NetPlayCreateRoom(const std::string& ipaddress, int port, - const std::string& username, const std::string& password, - const std::string& room_name, int max_players); -NetPlayStatus NetPlayJoinRoom(const std::string& ipaddress, int port, - const std::string& username, const std::string& password); -std::vector<std::string> NetPlayRoomInfo(); -bool NetPlayIsJoined(); -bool NetPlayIsHostedRoom(); -bool NetPlayIsModerator(); -void NetPlaySendMessage(const std::string& msg); -void NetPlayKickUser(const std::string& username); -void NetPlayBanUser(const std::string& username); -void NetPlayLeaveRoom(); -std::string NetPlayGetConsoleId(); -void NetworkShutdown(); -std::vector<std::string> NetPlayGetBanList(); -void NetPlayUnbanUser(const std::string& username); +class AndroidMultiplayer { +public: + explicit AndroidMultiplayer(Core::System& system, + std::shared_ptr<Core::AnnounceMultiplayerSession> session); + ~AndroidMultiplayer(); + + bool NetworkInit(); + + void AddNetPlayMessage(int status, const std::string& msg); + void AddNetPlayMessage(jint type, jstring msg); + + void ClearChat(); + + NetPlayStatus NetPlayCreateRoom(const std::string &ipaddress, int port, + const std::string &username, const std::string &preferredGameName, + const u64 &preferredGameId, const std::string &password, + const std::string &room_name, int max_players); + + NetPlayStatus NetPlayJoinRoom(const std::string &ipaddress, int port, + const std::string &username, const std::string &password); + + std::vector<std::string> NetPlayRoomInfo(); + + bool NetPlayIsJoined(); + + bool NetPlayIsHostedRoom(); + + bool NetPlayIsModerator(); + + void NetPlaySendMessage(const std::string &msg); + + void NetPlayKickUser(const std::string &username); + + void NetPlayBanUser(const std::string &username); + + void NetPlayLeaveRoom(); + + static void NetworkShutdown(); + + std::vector<std::string> NetPlayGetBanList(); + + void NetPlayUnbanUser(const std::string &username); + + std::vector<std::string> NetPlayGetPublicRooms(); + +private: + Core::System& system; + static std::unique_ptr<Network::VerifyUser::Backend> CreateVerifyBackend(bool use_validation) ; + std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; +}; |
