From 18e1a0fefac5bd0a08ef624dcf24af603649eff0 Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Tue, 9 Apr 2024 12:21:50 -0400 Subject: [PATCH] chore: migrate ConnectedUser map to MutexMap --- database/3ds/get_user_friends.go | 3 +- ...t_friend_request_and_return_friend_info.go | 4 +- database/wiiu/get_user_friend_list.go | 4 +- globals/globals.go | 2 +- grpc/send_user_notification_wiiu.go | 4 +- init.go | 6 ++- nex/friends-3ds/add_friendship_by_pid.go | 4 +- nex/friends-3ds/get_friend_presence.go | 6 +-- nex/friends-3ds/sync_friend.go | 4 +- nex/friends-3ds/update_presence.go | 9 +++-- nex/friends-wiiu/accept_friend_request.go | 40 ++++++++++--------- nex/friends-wiiu/add_friend_request.go | 4 +- nex/friends-wiiu/cancel_friend_request.go | 4 +- nex/friends-wiiu/remove_friend.go | 4 +- .../update_and_get_all_information.go | 10 +++-- nex/friends-wiiu/update_presence.go | 8 ++-- nex/secure-connection/register_ex.go | 2 +- nex/secure.go | 7 ++-- notifications/3ds/send_comment_update.go | 4 +- notifications/3ds/send_favorite_update.go | 4 +- notifications/3ds/send_mii_notification.go | 4 +- notifications/3ds/send_presence_update.go | 4 +- notifications/3ds/send_user_went_offline.go | 4 +- notifications/wiiu/send_presence_update.go | 4 +- notifications/wiiu/send_user_went_offline.go | 4 +- 25 files changed, 81 insertions(+), 72 deletions(-) diff --git a/database/3ds/get_user_friends.go b/database/3ds/get_user_friends.go index 2a9e0ef..95ecb2f 100644 --- a/database/3ds/get_user_friends.go +++ b/database/3ds/get_user_friends.go @@ -13,8 +13,7 @@ func GetUserFriends(pid uint32) (*types.List[*friends_3ds_types.FriendRelationsh friendRelationships := types.NewList[*friends_3ds_types.FriendRelationship]() friendRelationships.Type = friends_3ds_types.NewFriendRelationship() - rows, err := database.Postgres.Query(` - SELECT user2_pid, type FROM "3ds".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100`, pid) + rows, err := database.Postgres.Query("SELECT user2_pid, type FROM \"3ds\".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100", pid) if err != nil { if err == sql.ErrNoRows { return friendRelationships, database.ErrEmptyList diff --git a/database/wiiu/accept_friend_request_and_return_friend_info.go b/database/wiiu/accept_friend_request_and_return_friend_info.go index 21f7a50..79806be 100644 --- a/database/wiiu/accept_friend_request_and_return_friend_info.go +++ b/database/wiiu/accept_friend_request_and_return_friend_info.go @@ -59,10 +59,10 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi } friendInfo := friends_wiiu_types.NewFriendInfo() - connectedUser := globals.ConnectedUsers[senderPID] + connectedUser, ok := globals.ConnectedUsers.Get(senderPID) var lastOnline *types.DateTime - if connectedUser != nil { + if ok && connectedUser != nil { // * Online friendInfo.NNAInfo = connectedUser.NNAInfo friendInfo.Presence = connectedUser.PresenceV2 diff --git a/database/wiiu/get_user_friend_list.go b/database/wiiu/get_user_friend_list.go index 35286b3..4282d93 100644 --- a/database/wiiu/get_user_friend_list.go +++ b/database/wiiu/get_user_friend_list.go @@ -35,10 +35,10 @@ func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], } friendInfo := friends_wiiu_types.NewFriendInfo() - connectedUser := globals.ConnectedUsers[friendPID] + connectedUser, ok := globals.ConnectedUsers.Get(friendPID) var lastOnline *types.DateTime - if connectedUser != nil { + if ok && connectedUser != nil { // * Online friendInfo.NNAInfo = connectedUser.NNAInfo friendInfo.Presence = connectedUser.PresenceV2 diff --git a/globals/globals.go b/globals/globals.go index abbfc3d..928e62c 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -16,7 +16,7 @@ var AuthenticationServer *nex.PRUDPServer var AuthenticationEndpoint *nex.PRUDPEndPoint var SecureServer *nex.PRUDPServer var SecureEndpoint *nex.PRUDPEndPoint -var ConnectedUsers map[uint32]*types.ConnectedUser +var ConnectedUsers *nex.MutexMap[uint32, *types.ConnectedUser] var AESKey []byte var GRPCAccountClientConnection *grpc.ClientConn var GRPCAccountClient pb.AccountClient diff --git a/grpc/send_user_notification_wiiu.go b/grpc/send_user_notification_wiiu.go index e411900..2656bb5 100644 --- a/grpc/send_user_notification_wiiu.go +++ b/grpc/send_user_notification_wiiu.go @@ -13,9 +13,9 @@ import ( // SendUserNotificationWiiU implements helloworld.SendUserNotificationWiiU func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb.SendUserNotificationWiiURequest) (*empty.Empty, error) { - connectedUser := globals.ConnectedUsers[in.GetPid()] + connectedUser, ok := globals.ConnectedUsers.Get(in.GetPid()) - if connectedUser != nil { + if ok && connectedUser != nil { rmcRequest := nex.NewRMCRequest(globals.SecureEndpoint) rmcRequest.ProtocolID = nintendo_notifications.ProtocolID rmcRequest.CallID = 3810693103 diff --git a/init.go b/init.go index fb0b883..336dc21 100644 --- a/init.go +++ b/init.go @@ -11,6 +11,7 @@ import ( "github.com/PretendoNetwork/friends/globals" "github.com/PretendoNetwork/friends/types" pb "github.com/PretendoNetwork/grpc-go/account" + "github.com/PretendoNetwork/nex-go/v2" "github.com/PretendoNetwork/plogger-go" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -21,8 +22,9 @@ import ( func init() { globals.Logger = plogger.NewLogger() - globals.ConnectedUsers = make(map[uint32]*types.ConnectedUser) - // Setup RSA private key for token parsing + globals.ConnectedUsers = nex.NewMutexMap[uint32, *types.ConnectedUser]() + + // * Setup RSA private key for token parsing var err error err = godotenv.Load() diff --git a/nex/friends-3ds/add_friendship_by_pid.go b/nex/friends-3ds/add_friendship_by_pid.go index c091681..32a5269 100644 --- a/nex/friends-3ds/add_friendship_by_pid.go +++ b/nex/friends-3ds/add_friendship_by_pid.go @@ -23,8 +23,8 @@ func AddFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32 return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message } - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] - if connectedUser != nil { + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + if ok && connectedUser != nil { go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, pid.LegacyValue(), connection.PID()) } diff --git a/nex/friends-3ds/get_friend_presence.go b/nex/friends-3ds/get_friend_presence.go index 9fdff7c..2f8a697 100644 --- a/nex/friends-3ds/get_friend_presence.go +++ b/nex/friends-3ds/get_friend_presence.go @@ -18,12 +18,12 @@ func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pid presenceList.Type = friends_3ds_types.NewFriendPresence() pidList.Each(func(i int, pid *types.PID) bool { - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) - if connectedUser != nil && connectedUser.Presence != nil { + if ok && connectedUser != nil && connectedUser.Presence != nil { friendPresence := friends_3ds_types.NewFriendPresence() friendPresence.PID = pid.Copy().(*types.PID) - friendPresence.Presence = globals.ConnectedUsers[pid.LegacyValue()].Presence + friendPresence.Presence = connectedUser.Presence presenceList.Append(friendPresence) } diff --git a/nex/friends-3ds/sync_friend.go b/nex/friends-3ds/sync_friend.go index ee6faad..6215b8a 100644 --- a/nex/friends-3ds/sync_friend.go +++ b/nex/friends-3ds/sync_friend.go @@ -64,8 +64,8 @@ func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc *types relationships = append(relationships, relationship) // * Alert the other side, in case they weren't able to get our presence data - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] - if connectedUser != nil { + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + if ok && connectedUser != nil { go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, pid.LegacyValue(), connection.PID()) } } diff --git a/nex/friends-3ds/update_presence.go b/nex/friends-3ds/update_presence.go index ad6b549..f8565cf 100644 --- a/nex/friends-3ds/update_presence.go +++ b/nex/friends-3ds/update_presence.go @@ -30,18 +30,19 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen go notifications_3ds.SendPresenceUpdate(connection, currentPresence) pid := connection.PID().LegacyValue() + connectedUser, ok := globals.ConnectedUsers.Get(pid) - if globals.ConnectedUsers[pid] == nil { + if !ok || connectedUser == nil { // TODO - Figure out why this is getting removed - connectedUser := friends_types.NewConnectedUser() + connectedUser = friends_types.NewConnectedUser() connectedUser.PID = pid connectedUser.Platform = friends_types.CTR connectedUser.Connection = connection - globals.ConnectedUsers[pid] = connectedUser + globals.ConnectedUsers.Set(pid, connectedUser) } - globals.ConnectedUsers[pid].Presence = currentPresence + connectedUser.Presence = currentPresence rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil) rmcResponse.ProtocolID = friends_3ds.ProtocolID diff --git a/nex/friends-wiiu/accept_friend_request.go b/nex/friends-wiiu/accept_friend_request.go index 58c78eb..2a2cf43 100644 --- a/nex/friends-wiiu/accept_friend_request.go +++ b/nex/friends-wiiu/accept_friend_request.go @@ -30,30 +30,32 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i } friendPID := friendInfo.NNAInfo.PrincipalBasicInfo.PID.LegacyValue() - connectedUser := globals.ConnectedUsers[friendPID] + connectedUser, ok := globals.ConnectedUsers.Get(friendPID) - if connectedUser != nil { + if ok && connectedUser != nil { senderPID := connection.PID().LegacyValue() - senderConnectedUser := globals.ConnectedUsers[senderPID] + senderConnectedUser, ok := globals.ConnectedUsers.Get(senderPID) - senderFriendInfo := friends_wiiu_types.NewFriendInfo() + if ok && senderConnectedUser != nil { + senderFriendInfo := friends_wiiu_types.NewFriendInfo() - senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo - senderFriendInfo.Presence = senderConnectedUser.PresenceV2 - status, err := database_wiiu.GetUserComment(senderPID) - if err != nil { - globals.Logger.Critical(err.Error()) - senderFriendInfo.Status = friends_wiiu_types.NewComment() - senderFriendInfo.Status.LastChanged = types.NewDateTime(0) - } else { - senderFriendInfo.Status = status + senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo + senderFriendInfo.Presence = senderConnectedUser.PresenceV2 + status, err := database_wiiu.GetUserComment(senderPID) + if err != nil { + globals.Logger.Critical(err.Error()) + senderFriendInfo.Status = friends_wiiu_types.NewComment() + senderFriendInfo.Status.LastChanged = types.NewDateTime(0) + } else { + senderFriendInfo.Status = status + } + + senderFriendInfo.BecameFriend = friendInfo.BecameFriend + senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO - Change this + senderFriendInfo.Unknown = types.NewPrimitiveU64(0) + + go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Connection, senderFriendInfo) } - - senderFriendInfo.BecameFriend = friendInfo.BecameFriend - senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO - Change this - senderFriendInfo.Unknown = types.NewPrimitiveU64(0) - - go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Connection, senderFriendInfo) } rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings()) diff --git a/nex/friends-wiiu/add_friend_request.go b/nex/friends-wiiu/add_friend_request.go index a74e6b5..a048a89 100644 --- a/nex/friends-wiiu/add_friend_request.go +++ b/nex/friends-wiiu/add_friend_request.go @@ -117,9 +117,9 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid friendInfo.LastOnline = types.NewDateTime(0) friendInfo.Unknown = types.NewPrimitiveU64(0) - recipientClient := globals.ConnectedUsers[recipientPID] + recipientClient, ok := globals.ConnectedUsers.Get(recipientPID) - if recipientClient != nil { + if ok && recipientClient != nil { friendRequestNotificationData := friends_wiiu_types.NewFriendRequest() friendRequestNotificationData.PrincipalInfo = senderPrincipalInfo diff --git a/nex/friends-wiiu/cancel_friend_request.go b/nex/friends-wiiu/cancel_friend_request.go index 80ee77d..ac7a0ec 100644 --- a/nex/friends-wiiu/cancel_friend_request.go +++ b/nex/friends-wiiu/cancel_friend_request.go @@ -28,8 +28,8 @@ func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, i } } - connectedUser := globals.ConnectedUsers[pid] - if connectedUser != nil { + connectedUser, ok := globals.ConnectedUsers.Get(pid) + if ok && connectedUser != nil { // * This may send the friend removed notification, but they are the same. go notifications_wiiu.SendFriendshipRemoved(connectedUser.Connection, connection.PID()) } diff --git a/nex/friends-wiiu/remove_friend.go b/nex/friends-wiiu/remove_friend.go index bb17352..ef819f3 100644 --- a/nex/friends-wiiu/remove_friend.go +++ b/nex/friends-wiiu/remove_friend.go @@ -28,8 +28,8 @@ func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *typ } } - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] - if connectedUser != nil { + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) + if ok && connectedUser != nil { go notifications_wiiu.SendFriendshipRemoved(connectedUser.Connection, pid) } diff --git a/nex/friends-wiiu/update_and_get_all_information.go b/nex/friends-wiiu/update_and_get_all_information.go index e69bdd4..a12d115 100644 --- a/nex/friends-wiiu/update_and_get_all_information.go +++ b/nex/friends-wiiu/update_and_get_all_information.go @@ -24,19 +24,21 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui // * Get user information pid := connection.PID().LegacyValue() + connectedUser, ok := globals.ConnectedUsers.Get(pid) - if globals.ConnectedUsers[pid] == nil { + if !ok || connectedUser == nil { // TODO - Figure out why this is getting removed connectedUser := friends_types.NewConnectedUser() connectedUser.PID = pid connectedUser.Platform = friends_types.WUP connectedUser.Connection = connection + // TODO - Find a clean way to create a NNAInfo? - globals.ConnectedUsers[pid] = connectedUser + globals.ConnectedUsers.Set(pid, connectedUser) } - globals.ConnectedUsers[pid].NNAInfo = nnaInfo - globals.ConnectedUsers[pid].PresenceV2 = presence + connectedUser.NNAInfo = nnaInfo + connectedUser.PresenceV2 = presence principalPreference, err := database_wiiu.GetUserPrincipalPreference(pid) if err != nil { diff --git a/nex/friends-wiiu/update_presence.go b/nex/friends-wiiu/update_presence.go index 7ed0a8e..52810e7 100644 --- a/nex/friends-wiiu/update_presence.go +++ b/nex/friends-wiiu/update_presence.go @@ -23,7 +23,9 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen presence.Online = types.NewPrimitiveBool(true) // * Force online status. I have no idea why this is always false presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT?? - if globals.ConnectedUsers[pid] == nil { + connectedUser, ok := globals.ConnectedUsers.Get(pid) + + if !ok || connectedUser == nil { // TODO - Figure out why this is getting removed connectedUser := friends_types.NewConnectedUser() connectedUser.PID = pid @@ -31,10 +33,10 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen connectedUser.Connection = connection // TODO - Find a clean way to create a NNAInfo? - globals.ConnectedUsers[pid] = connectedUser + globals.ConnectedUsers.Set(pid, connectedUser) } - globals.ConnectedUsers[pid].PresenceV2 = presence + connectedUser.PresenceV2 = presence notifications_wiiu.SendPresenceUpdate(presence) diff --git a/nex/secure-connection/register_ex.go b/nex/secure-connection/register_ex.go index 8f3b48b..9e9b699 100644 --- a/nex/secure-connection/register_ex.go +++ b/nex/secure-connection/register_ex.go @@ -58,7 +58,7 @@ func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs urlPublic := types.NewString("") if retval.IsSuccess() { - globals.ConnectedUsers[pid] = user + globals.ConnectedUsers.Set(pid, user) localStation, _ := vecMyURLs.Get(0) diff --git a/nex/secure.go b/nex/secure.go index 547fd52..a19632e 100644 --- a/nex/secure.go +++ b/nex/secure.go @@ -30,12 +30,13 @@ func StartSecureServer() { globals.SecureEndpoint.OnConnectionEnded(func(connection *nex.PRUDPConnection) { pid := connection.PID().LegacyValue() + user, ok := globals.ConnectedUsers.Get(pid) - if globals.ConnectedUsers[pid] == nil { + if !ok || user == nil { return } - platform := globals.ConnectedUsers[pid].Platform + platform := user.Platform lastOnline := types.NewDateTime(0) lastOnline.FromTimestamp(time.Now()) @@ -55,7 +56,7 @@ func StartSecureServer() { notifications_3ds.SendUserWentOfflineGlobally(connection) } - delete(globals.ConnectedUsers, pid) + globals.ConnectedUsers.Delete(pid) }) registerCommonSecureServerProtocols() diff --git a/notifications/3ds/send_comment_update.go b/notifications/3ds/send_comment_update.go index ab68e99..179e671 100644 --- a/notifications/3ds/send_comment_update.go +++ b/notifications/3ds/send_comment_update.go @@ -46,9 +46,9 @@ func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) { } friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/3ds/send_favorite_update.go b/notifications/3ds/send_favorite_update.go index e2f0163..dee92ce 100644 --- a/notifications/3ds/send_favorite_update.go +++ b/notifications/3ds/send_favorite_update.go @@ -43,9 +43,9 @@ func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_ty } friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/3ds/send_mii_notification.go b/notifications/3ds/send_mii_notification.go index 4c2e832..7675fec 100644 --- a/notifications/3ds/send_mii_notification.go +++ b/notifications/3ds/send_mii_notification.go @@ -45,9 +45,9 @@ func SendMiiUpdateNotification(connection *nex.PRUDPConnection) { } friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/3ds/send_presence_update.go b/notifications/3ds/send_presence_update.go index 09e02b8..6cd76ae 100644 --- a/notifications/3ds/send_presence_update.go +++ b/notifications/3ds/send_presence_update.go @@ -43,9 +43,9 @@ func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_t } friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool { - connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(friend.PID.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/3ds/send_user_went_offline.go b/notifications/3ds/send_user_went_offline.go index b428d2f..3d64306 100644 --- a/notifications/3ds/send_user_went_offline.go +++ b/notifications/3ds/send_user_went_offline.go @@ -52,9 +52,9 @@ func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { notificationRequestBytes := notificationRequest.Bytes() - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/wiiu/send_presence_update.go b/notifications/wiiu/send_presence_update.go index 8c8386c..fedff9e 100644 --- a/notifications/wiiu/send_presence_update.go +++ b/notifications/wiiu/send_presence_update.go @@ -69,9 +69,9 @@ func SendPresenceUpdate(presence *friends_wiiu_types.NintendoPresenceV2) { } friendPID := friend.NNAInfo.PrincipalBasicInfo.PID - connectedUser := globals.ConnectedUsers[friendPID.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(friendPID.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) requestPacket.SetType(constants.DataPacket) diff --git a/notifications/wiiu/send_user_went_offline.go b/notifications/wiiu/send_user_went_offline.go index 60bc9da..fa2a152 100644 --- a/notifications/wiiu/send_user_went_offline.go +++ b/notifications/wiiu/send_user_went_offline.go @@ -57,9 +57,9 @@ func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) { notificationRequestBytes := notificationRequest.Bytes() - connectedUser := globals.ConnectedUsers[pid.LegacyValue()] + connectedUser, ok := globals.ConnectedUsers.Get(pid.LegacyValue()) - if connectedUser != nil { + if ok && connectedUser != nil { requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil) requestPacket.SetType(constants.DataPacket)