Files
Beyhan Oğur d5f52cc3d3 first commit
2026-09-03 04:45:36 +03:00

27 KiB
Raw Permalink Blame History

Communication Tools

**Referenced Files in This Document** - [ChatManager.cs](file://ClassicAssist.Shared/Data/Chat/ChatManager.cs) - [ChatMessage.cs](file://ClassicAssist.Shared/Data/Chat/ChatMessage.cs) - [ChatUser.cs](file://ClassicAssist.Shared/Data/Chat/ChatUser.cs) - [ClilocFilter.cs](file://ClassicAssist.Shared/Data/Filters/ClilocFilter.cs) - [RepeatedMessagesFilter.cs](file://ClassicAssist.Shared/Data/Filters/RepeatedMessagesFilter.cs) - [FilterEntry.cs](file://ClassicAssist.Shared/Data/Filters/FilterEntry.cs) - [IConfigurableFilter.cs](file://ClassicAssist.Shared/Data/Filters/IConfigurableFilter.cs) - [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs) - [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs) - [IncomingPacketFilters.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketFilters.cs) - [OutgoingPacketFilters.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketFilters.cs) - [PacketHandler.cs](file://ClassicAssist.Shared/UO/Network/PacketHandler.cs) - [UnicodeText.cs](file://ClassicAssist.Shared/UO/Network/Packets/UnicodeText.cs) - [Cliloc.cs](file://ClassicAssist.Shared/UO/Data/Cliloc.cs) - [FriendsTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/FriendsTabControl.axaml.cs) - [FriendsTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/FriendsTabViewModel.cs) - [FriendEntry.cs](file://ClassicAssist.Shared/Data/Friends/FriendEntry.cs) - [FriendsCommands.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/FriendsCommands.cs) - [ChatWindow.xaml.cs](file://ClassicAssist.Avalonia/Views/ChatWindow.axaml.cs) - [ChatViewModel.cs](file://ClassicAssist.Avalonia/ViewModels/ChatViewModel.cs) - [ClilocFilterConfigureWindow.xaml.cs](file://ClassicAssist.Avalonia/Views/Filters/ClilocFilterConfigureWindow.axaml.cs) - [ClilocFilterConfigureViewModel.cs](file://ClassicAssist.Avalonia/ViewModels/Filters/ClilocFilterConfigureViewModel.cs)

Table of Contents

  1. Introduction
  2. Project Structure
  3. Core Components
  4. Architecture Overview
  5. Detailed Component Analysis
  6. Dependency Analysis
  7. Performance Considerations
  8. Troubleshooting Guide
  9. Conclusion

Introduction

This document explains the communication tools in ClassicAssist.Avalonia with a focus on chat, friends, localization (cliloc), real-time protocols, filtering, and performance. It covers channel management, message filtering, logging/export, social features, status monitoring, party coordination, filter configuration (including regex support), integration with Ultima Online’s native chat system, and strategies for high-volume processing and memory management.

Project Structure

The communication subsystem spans shared data models, network handlers, filters, UI views, and view models:

  • Shared data models for chat, friends, and cliloc
  • Network layer for incoming/outgoing packets and routing
  • Filter pipeline for chat messages
  • Avalonia UI components for chat window and friends tab
  • Configuration UI for filters
graph TB
subgraph "Shared"
CM["ChatManager"]
MSG["ChatMessage"]
USER["ChatUser"]
CLF["ClilocFilter"]
RMF["RepeatedMessagesFilter"]
FE["FilterEntry"]
CF["IConfigurableFilter"]
IPH["IncomingPacketHandlers"]
OPH["OutgoingPacketHandlers"]
IPF["IncomingPacketFilters"]
OPF["OutgoingPacketFilters"]
PH["PacketHandler"]
UT["UnicodeText"]
CLILOC["Cliloc"]
FF["FriendEntry"]
FVM["FriendsTabViewModel"]
FCMD["FriendsCommands"]
end
subgraph "Avalonia UI"
CW["ChatWindow"]
CVM["ChatViewModel"]
FCT["FriendsTabControl"]
CLFCW["ClilocFilterConfigureWindow"]
CLFCVM["ClilocFilterConfigureViewModel"]
end
CM --> MSG
CM --> USER
CM --> CLF
CM --> RMF
CM --> FE
CM --> CF
IPH --> CM
OPH --> CM
IPF --> CM
OPF --> CM
PH --> IPH
PH --> OPH
UT --> CM
CLILOC --> CLF
FVM --> FF
FCMD --> FVM
CW --> CVM
CVM --> CM
FCT --> FVM
CLFCW --> CLFCVM
CLFCVM --> CLF

Diagram sources

Section sources

Core Components

  • Chat system: central manager orchestrating channels, messages, users, filters, logging, and export hooks.
  • Friends system: list management, presence/status, commands for invites/parties.
  • Cliloc localization: text lookup and filtering by cliloc IDs.
  • Network protocol: packet handlers for chat-related packets, filter pipeline, and routing to managers.
  • UI: chat window and friends tab bound to view models that interact with managers.

Key responsibilities:

  • Channel management: grouping messages by type/channel and controlling visibility.
  • Message filtering: built-in and custom filters including regex-based rules.
  • Logging and export: persisting messages and exporting logs for analysis.
  • Social features: friend list CRUD, status updates, invitations, and party coordination.
  • Localization: resolving cliloc entries and applying filters based on localized text or IDs.

Section sources

Architecture Overview

The communication architecture integrates UO network packets into a layered pipeline:

  • PacketHandler routes incoming/outgoing packets to specific handlers.
  • IncomingPacketHandlers parse chat and social packets and forward events to ChatManager and Friends systems.
  • OutgoingPacketHandlers send chat and social actions back to the server.
  • IncomingPacketFilters and OutgoingPacketFilters provide interception points for inspection/modification.
  • ChatManager applies filters (regex, repeated messages, cliloc-based) and manages channels/users/messages.
  • UI layers bind to view models which call into managers for display and user actions.
sequenceDiagram
participant Net as "PacketHandler"
participant InH as "IncomingPacketHandlers"
participant InF as "IncomingPacketFilters"
participant CM as "ChatManager"
participant FM as "FriendsTabViewModel"
participant UI as "ChatWindow/ChatViewModel"
Net->>InH : "Dispatch incoming packet"
InH->>InF : "Apply incoming filters"
InF-->>InH : "Filtered result"
InH->>CM : "Publish chat/social event"
CM->>CM : "Apply filters (regex, repeated, cliloc)"
CM-->>UI : "Notify new message/channel update"
UI->>FM : "Sync friends/party state"
FM-->>UI : "Status changes"

Diagram sources

Detailed Component Analysis

Chat System

Responsibilities:

  • Channel management: categorize messages by channel type and control visibility.
  • Message lifecycle: creation, filtering, persistence, and export.
  • User tracking: maintain ChatUser instances per sender.
  • Integration: receives parsed chat from UnicodeText via handlers.
classDiagram
class ChatManager {
+AddMessage(message)
+GetChannel(channelType)
+RemoveOldEntries(maxCount)
+ExportLog(path)
+SubscribeToEvents()
}
class ChatMessage {
+Sender
+Content
+Channel
+Timestamp
}
class ChatUser {
+Name
+Serial
+LastSeen
}
class ClilocFilter {
+Matches(clilocId, text)
+Configure(options)
}
class RepeatedMessagesFilter {
+ShouldSuppress(previous, current)
}
class FilterEntry {
+Pattern
+Enabled
+Regex
}
class IConfigurableFilter {
<<interface>>
+Configure(options)
}
ChatManager --> ChatMessage : "creates/manages"
ChatManager --> ChatUser : "tracks"
ChatManager --> ClilocFilter : "applies"
ChatManager --> RepeatedMessagesFilter : "applies"
ChatManager --> FilterEntry : "iterates"
ClilocFilter ..|> IConfigurableFilter
RepeatedMessagesFilter ..|> IConfigurableFilter

Diagram sources

Section sources

Friends List and Party Coordination

Responsibilities:

  • Maintain friend entries with status and metadata.
  • Provide commands for inviting, accepting/rejecting parties, and viewing status.
  • UI binds to view model for interactive management.
sequenceDiagram
participant UI as "FriendsTabControl"
participant VM as "FriendsTabViewModel"
participant CMD as "FriendsCommands"
participant NET as "OutgoingPacketHandlers"
participant S as "Server"
UI->>VM : "User action (invite/accept/reject)"
VM->>CMD : "Invoke command"
CMD->>NET : "Build and send packet"
NET->>S : "Transmit"
S-->>NET : "Response (status/party update)"
NET-->>VM : "Update state"
VM-->>UI : "Refresh list and status"

Diagram sources

Section sources

Cliloc Text System

Responsibilities:

  • Resolve localized strings using cliloc IDs.
  • Support filtering by cliloc ID or resolved text.
  • Provide configuration UI for filter options.
flowchart TD
Start(["Resolve Cliloc"]) --> Lookup["Lookup ID in Cliloc"]
Lookup --> Found{"Found?"}
Found --> |Yes| ReturnText["Return localized text"]
Found --> |No| Fallback["Fallback to raw ID"]
ReturnText --> ApplyFilter["Apply ClilocFilter"]
Fallback --> ApplyFilter
ApplyFilter --> End(["Result"])

Diagram sources

Section sources

Real-Time Communication Protocols and Routing

Responsibilities:

  • Parse and dispatch chat-related packets (e.g., UnicodeText).
  • Route events to ChatManager and friends/party handlers.
  • Provide filter hooks before/after processing.
sequenceDiagram
participant Client as "Client"
participant PH as "PacketHandler"
participant IN as "IncomingPacketHandlers"
participant CH as "ChatManager"
participant FR as "FriendsTabViewModel"
Client->>PH : "Send UnicodeText"
PH->>IN : "Route to handler"
IN->>CH : "Create ChatMessage"
CH->>CH : "Apply filters"
CH-->>FR : "Broadcast updates"

Diagram sources

Section sources

Filter Configuration and Custom Filters

Responsibilities:

  • Built-in filters: repeated messages suppression, cliloc-based matching.
  • Regex support via FilterEntry patterns.
  • Configurable filters interface for advanced customization.
  • UI for configuring cliloc filters.
flowchart TD
Entry(["New Message"]) --> Iterate["Iterate FilterEntry list"]
Iterate --> CheckEnabled{"Enabled?"}
CheckEnabled --> |No| Next["Next filter"]
CheckEnabled --> |Yes| Match["Match pattern (regex if set)"]
Match --> Hit{"Hit?"}
Hit --> |Yes| Action["Suppress/Tag/Modify"]
Hit --> |No| Next
Next --> Done{"More filters?"}
Done --> |Yes| Iterate
Done --> |No| Publish["Publish to ChatManager"]

Diagram sources

Section sources

Integration with Ultima Online Native Chat and Protocol Handling

Responsibilities:

  • Map UO chat packets to internal ChatMessage objects.
  • Preserve channel semantics and sender identity.
  • Ensure outgoing chat commands are serialized correctly.
sequenceDiagram
participant UO as "UO Server"
participant PH as "PacketHandler"
participant IN as "IncomingPacketHandlers"
participant CH as "ChatManager"
participant UI as "ChatViewModel"
UO->>PH : "UnicodeText packet"
PH->>IN : "Parse"
IN->>CH : "Create ChatMessage"
CH->>UI : "Notify channel update"
UI-->>UO : "User sends chat via OutgoingPacketHandlers"

Diagram sources

Section sources

Dependency Analysis

High-level dependencies among communication components:

graph LR
PH["PacketHandler"] --> INH["IncomingPacketHandlers"]
PH --> OPH["OutgoingPacketHandlers"]
INH --> CM["ChatManager"]
OPH --> CM
INH --> FRM["FriendsTabViewModel"]
OPH --> FRM
CM --> CLF["ClilocFilter"]
CM --> RMF["RepeatedMessagesFilter"]
CM --> FE["FilterEntry"]
CLF --> CLILOC["Cliloc"]
UI["ChatWindow/ChatViewModel"] --> CM
FUI["FriendsTabControl"] --> FRM

Diagram sources

Section sources

Performance Considerations

  • High-volume chat processing:
    • Use efficient filtering order; place frequent matches early.
    • Prefer compiled regex patterns where supported to reduce overhead.
    • Limit retained message history with bounded collections and periodic cleanup.
  • Memory management:
    • Avoid retaining large string copies; reuse buffers where possible.
    • Unsubscribe from events when windows close to prevent leaks.
    • Export logs asynchronously to avoid blocking UI thread.
  • UI responsiveness:
    • Batch updates to observable collections.
    • Debounce heavy operations like log exports.
  • Network efficiency:
    • Coalesce outgoing chat commands when appropriate.
    • Leverage packet filters to drop unnecessary traffic early.

[No sources needed since this section provides general guidance]

Troubleshooting Guide

Common issues and diagnostics:

  • Messages not appearing:
    • Verify incoming packet handlers route to ChatManager.
    • Check filter configurations (regex, cliloc) for over-aggressive suppression.
  • Incorrect localization:
    • Confirm cliloc ID mapping and fallback behavior.
  • Friends/party state out of sync:
    • Inspect outgoing/incoming packet flows for missing updates.
    • Validate command invocations and response handling.
  • Performance degradation:
    • Profile filter execution time and message retention size.
    • Monitor UI thread workloads during export operations.

Section sources

Conclusion

ClassicAssist.Avalonia’s communication tools integrate tightly with Ultima Online’s protocol while providing robust chat management, social features, localization, and extensible filtering. The layered design separates concerns across network handlers, managers, filters, and UI, enabling scalability and maintainability. By following the performance and troubleshooting recommendations, users can optimize for high-volume environments and ensure reliable operation.