network, yuzu: Improve variable naming and style consistency
This commit is contained in:
parent
6b5667dfa5
commit
6a2dcc8b3d
14 changed files with 53 additions and 47 deletions
|
@ -10,8 +10,8 @@
|
|||
namespace Network {
|
||||
|
||||
RoomNetwork::RoomNetwork() {
|
||||
g_room = std::make_shared<Room>();
|
||||
g_room_member = std::make_shared<RoomMember>();
|
||||
m_room = std::make_shared<Room>();
|
||||
m_room_member = std::make_shared<RoomMember>();
|
||||
}
|
||||
|
||||
bool RoomNetwork::Init() {
|
||||
|
@ -19,30 +19,30 @@ bool RoomNetwork::Init() {
|
|||
LOG_ERROR(Network, "Error initalizing ENet");
|
||||
return false;
|
||||
}
|
||||
g_room = std::make_shared<Room>();
|
||||
g_room_member = std::make_shared<RoomMember>();
|
||||
m_room = std::make_shared<Room>();
|
||||
m_room_member = std::make_shared<RoomMember>();
|
||||
LOG_DEBUG(Network, "initialized OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::weak_ptr<Room> RoomNetwork::GetRoom() {
|
||||
return g_room;
|
||||
return m_room;
|
||||
}
|
||||
|
||||
std::weak_ptr<RoomMember> RoomNetwork::GetRoomMember() {
|
||||
return g_room_member;
|
||||
return m_room_member;
|
||||
}
|
||||
|
||||
void RoomNetwork::Shutdown() {
|
||||
if (g_room_member) {
|
||||
if (g_room_member->IsConnected())
|
||||
g_room_member->Leave();
|
||||
g_room_member.reset();
|
||||
if (m_room_member) {
|
||||
if (m_room_member->IsConnected())
|
||||
m_room_member->Leave();
|
||||
m_room_member.reset();
|
||||
}
|
||||
if (g_room) {
|
||||
if (g_room->GetState() == Room::State::Open)
|
||||
g_room->Destroy();
|
||||
g_room.reset();
|
||||
if (m_room) {
|
||||
if (m_room->GetState() == Room::State::Open)
|
||||
m_room->Destroy();
|
||||
m_room.reset();
|
||||
}
|
||||
enet_deinitialize();
|
||||
LOG_DEBUG(Network, "shutdown OK");
|
||||
|
|
|
@ -27,8 +27,8 @@ public:
|
|||
void Shutdown();
|
||||
|
||||
private:
|
||||
std::shared_ptr<RoomMember> g_room_member; ///< RoomMember (Client) for network games
|
||||
std::shared_ptr<Room> g_room; ///< Room (Server) for network games
|
||||
std::shared_ptr<RoomMember> m_room_member; ///< RoomMember (Client) for network games
|
||||
std::shared_ptr<Room> m_room; ///< Room (Server) for network games
|
||||
};
|
||||
|
||||
} // namespace Network
|
||||
|
|
|
@ -29,8 +29,8 @@ public:
|
|||
std::atomic<State> state{State::Closed}; ///< Current state of the room.
|
||||
RoomInformation room_information; ///< Information about this room.
|
||||
|
||||
std::string verify_UID; ///< A GUID which may be used for verfication.
|
||||
mutable std::mutex verify_UID_mutex; ///< Mutex for verify_UID
|
||||
std::string verify_uid; ///< A GUID which may be used for verfication.
|
||||
mutable std::mutex verify_uid_mutex; ///< Mutex for verify_uid
|
||||
|
||||
std::string password; ///< The password required to connect to this room.
|
||||
|
||||
|
@ -369,8 +369,8 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
|||
|
||||
std::string uid;
|
||||
{
|
||||
std::lock_guard lock(verify_UID_mutex);
|
||||
uid = verify_UID;
|
||||
std::lock_guard lock(verify_uid_mutex);
|
||||
uid = verify_uid;
|
||||
}
|
||||
member.user_data = verify_backend->LoadUserData(uid, token);
|
||||
|
||||
|
@ -1056,8 +1056,8 @@ const RoomInformation& Room::GetRoomInformation() const {
|
|||
}
|
||||
|
||||
std::string Room::GetVerifyUID() const {
|
||||
std::lock_guard lock(room_impl->verify_UID_mutex);
|
||||
return room_impl->verify_UID;
|
||||
std::lock_guard lock(room_impl->verify_uid_mutex);
|
||||
return room_impl->verify_uid;
|
||||
}
|
||||
|
||||
Room::BanList Room::GetBanList() const {
|
||||
|
@ -1086,8 +1086,8 @@ bool Room::HasPassword() const {
|
|||
}
|
||||
|
||||
void Room::SetVerifyUID(const std::string& uid) {
|
||||
std::lock_guard lock(room_impl->verify_UID_mutex);
|
||||
room_impl->verify_UID = uid;
|
||||
std::lock_guard lock(room_impl->verify_uid_mutex);
|
||||
room_impl->verify_uid = uid;
|
||||
}
|
||||
|
||||
void Room::Destroy() {
|
||||
|
|
|
@ -416,8 +416,9 @@ void RoomMember::RoomMemberImpl::Disconnect() {
|
|||
room_information.member_slots = 0;
|
||||
room_information.name.clear();
|
||||
|
||||
if (!server)
|
||||
if (!server) {
|
||||
return;
|
||||
}
|
||||
enet_peer_disconnect(server, 0);
|
||||
|
||||
ENetEvent event;
|
||||
|
@ -483,8 +484,9 @@ template <typename T>
|
|||
void RoomMember::RoomMemberImpl::Invoke(const T& data) {
|
||||
std::lock_guard lock(callback_mutex);
|
||||
CallbackSet<T> callback_set = callbacks.Get<T>();
|
||||
for (auto const& callback : callback_set)
|
||||
for (auto const& callback : callback_set) {
|
||||
(*callback)(data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -10,7 +10,7 @@ Backend::~Backend() = default;
|
|||
|
||||
NullBackend::~NullBackend() = default;
|
||||
|
||||
UserData NullBackend::LoadUserData([[maybe_unused]] const std::string& verify_UID,
|
||||
UserData NullBackend::LoadUserData([[maybe_unused]] const std::string& verify_uid,
|
||||
[[maybe_unused]] const std::string& token) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ public:
|
|||
|
||||
/**
|
||||
* Verifies the given token and loads the information into a UserData struct.
|
||||
* @param verify_UID A GUID that may be used for verification.
|
||||
* @param verify_uid A GUID that may be used for verification.
|
||||
* @param token A token that contains user data and verification data. The format and content is
|
||||
* decided by backends.
|
||||
*/
|
||||
virtual UserData LoadUserData(const std::string& verify_UID, const std::string& token) = 0;
|
||||
virtual UserData LoadUserData(const std::string& verify_uid, const std::string& token) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ class NullBackend final : public Backend {
|
|||
public:
|
||||
~NullBackend();
|
||||
|
||||
UserData LoadUserData(const std::string& verify_UID, const std::string& token) override;
|
||||
UserData LoadUserData(const std::string& verify_uid, const std::string& token) override;
|
||||
};
|
||||
|
||||
} // namespace Network::VerifyUser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue