Skip to content

[Core] Split PushLogic's message processing methods#74

Merged
Linwenxuan04 merged 5 commits into
LagrangeDev:mainfrom
kengwang:chore/split-push-logic-handlers
Oct 17, 2025
Merged

[Core] Split PushLogic's message processing methods#74
Linwenxuan04 merged 5 commits into
LagrangeDev:mainfrom
kengwang:chore/split-push-logic-handlers

Conversation

@kengwang
Copy link
Copy Markdown
Contributor

Motivation

Split the big switch-case in PushLogic's Incoming method, to get better readability.

More

Make MessageBody nullable, it could be null in some cases

Copilot AI review requested due to automatic review settings October 16, 2025 18:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the PushLogic class by extracting its large switch-case message handling logic into separate handler classes, improving code maintainability and readability. Additionally, it makes the MessageBody property nullable to handle cases where it may not be present.

Key Changes:

  • Refactored message processing from a monolithic switch-case into individual handler classes
  • Implemented a handler registration system using reflection and frozen dictionaries for efficient lookup
  • Made MessageBody nullable in CommonMessage to handle missing message bodies gracefully

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Lagrange.Core/Message/MessagePacker.cs Added null checks for MessageBody and null-forgiving operator usage
Lagrange.Core/Internal/Packets/Message/NTMessageCommon.cs Changed MessageBody property to nullable type
Lagrange.Core/Internal/Logic/PushLogic.cs Refactored from switch-case to handler-based architecture with reflection-based handler discovery
Lagrange.Core/Internal/Logic/MsgPushHandlers/RichTextMsgHandler.cs Extracted rich text message handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupReactionHandler.cs Extracted group reaction handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupNudgeHandler.cs Extracted group nudge handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupMemberIncreaseHandler.cs Extracted group member increase handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupMemberDecreaseHandler.cs Extracted group member decrease handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupJoinHandler.cs Extracted group join handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupInviteHandler.cs Extracted group invite handling logic into dedicated handler
Lagrange.Core/Internal/Logic/MsgPushHandlers/FriendRequestHandler.cs Extracted friend request handling logic into dedicated handler

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Lagrange.Core/Internal/Logic/PushLogic.cs Outdated
Comment thread Lagrange.Core/Internal/Logic/MsgPushHandlers/GroupMemberDecreaseHandler.cs Outdated
kengwang and others added 2 commits October 17, 2025 10:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kengwang kengwang requested a review from Copilot October 17, 2025 02:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Lagrange.Core/Internal/Logic/PushLogic.cs Outdated
Comment thread Lagrange.Core/Message/MessagePacker.cs Outdated
Comment thread Lagrange.Core/Internal/Logic/MsgPushHandlers/FriendRequestHandler.cs Outdated
@kengwang kengwang requested a review from Linwenxuan04 October 17, 2025 14:35
@Linwenxuan04 Linwenxuan04 merged commit e681ad0 into LagrangeDev:main Oct 17, 2025
9 checks passed
@kengwang kengwang deleted the chore/split-push-logic-handlers branch November 4, 2025 13:29
Bemly pushed a commit to Bemly/CharonAnchor that referenced this pull request May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants