From e2d2a713a04adcb05ffb326ffb2c9b0d09429403 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 23:59:36 +0000 Subject: [PATCH] Add null check for sourceData in friend offline notification --- GenOnlineService/Constants.cs | 12 +++++++----- GenOnlineService/Constants_fixed.cs | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 GenOnlineService/Constants_fixed.cs diff --git a/GenOnlineService/Constants.cs b/GenOnlineService/Constants.cs index e83a909..bf32cd7 100644 --- a/GenOnlineService/Constants.cs +++ b/GenOnlineService/Constants.cs @@ -324,12 +324,14 @@ public static async Task DeleteSession(Int64 user_id, UserWebSocketInstance? old { // TODO_SOCIAL: Move this to a class - // inform any friends who are online that this person just came online + // inform any friends who are online that this person just came offline WebSocketMessage_Social_FriendStatusChanged friendStatusChangedEvent = new(); friendStatusChangedEvent.msg_id = (int)EWebSocketMessageID.SOCIAL_FRIEND_ONLINE_STATUS_CHANGED; + if (sourceData != null) + { friendStatusChangedEvent.display_name = sourceData.m_strDisplayName; - friendStatusChangedEvent.online = false; - byte[] bytesJSON = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(friendStatusChangedEvent)); + friendStatusChangedEvent.online = false; + byte[] bytesJSON = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(friendStatusChangedEvent)); if (sourceData != null) { @@ -831,12 +833,12 @@ public UserWebSocketInstance(Int64 ownerID, string strDisplayName, UserSocialCon m_UserID = ownerID; // TODO_SOCIAL: Move this to a class - // inform any friends who are online that this person just came online + // inform any friends who are online that this person just came offline WebSocketMessage_Social_FriendStatusChanged friendStatusChangedEvent = new(); friendStatusChangedEvent.msg_id = (int)EWebSocketMessageID.SOCIAL_FRIEND_ONLINE_STATUS_CHANGED; friendStatusChangedEvent.display_name = strDisplayName; friendStatusChangedEvent.online = true; - byte[] bytesJSON = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(friendStatusChangedEvent)); + byte[] bytesJSON = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(friendStatusChangedEvent)); // friends are reciprocal so we can just iterate our friends foreach (Int64 friendID in socialContainer.Friends) diff --git a/GenOnlineService/Constants_fixed.cs b/GenOnlineService/Constants_fixed.cs new file mode 100644 index 0000000..311c8dd --- /dev/null +++ b/GenOnlineService/Constants_fixed.cs @@ -0,0 +1 @@ +PLACEHOLDER \ No newline at end of file