Skip to content

refactor(interfaces): add unified protocol interfaces (IProtocolClient, IProtocolServer)#594

Merged
kcenon merged 1 commit into
mainfrom
refactor/issue-593-create-protocol-interfaces
Feb 1, 2026
Merged

refactor(interfaces): add unified protocol interfaces (IProtocolClient, IProtocolServer)#594
kcenon merged 1 commit into
mainfrom
refactor/issue-593-create-protocol-interfaces

Conversation

@kcenon

@kcenon kcenon commented Feb 1, 2026

Copy link
Copy Markdown
Owner

What

Summary

Introduces two core unified interfaces (i_protocol_client and i_protocol_server) that establish common contracts across all protocol implementations (TCP, UDP, HTTP, WebSocket, QUIC).

Change Type

  • Refactor (architectural improvement)

Affected Components

  • include/kcenon/network/interfaces/i_protocol_client.h - New client interface
  • include/kcenon/network/interfaces/i_protocol_server.h - New server interface

Why

Related Issues

Closes #593
Part of #577 (EPIC: Apply Facade pattern to reduce protocol header complexity)

Motivation

Currently, each protocol (TCP, UDP, HTTP, WebSocket, QUIC) has its own client/server structure with duplicated patterns. This creates:

  • Maintenance burden: Changes must be replicated across protocols
  • Learning curve: Developers must understand each protocol's unique structure
  • Testing complexity: Each protocol requires separate test infrastructure

These unified interfaces provide:

Who

Reviewers

@kcenon - Architecture review

When

Urgency

Target Release

Milestone: EPIC #577 completion

Where

Files Created

File Purpose Lines
include/kcenon/network/interfaces/i_protocol_client.h Unified client interface 342
include/kcenon/network/interfaces/i_protocol_server.h Unified server interface 342

Design Decisions

Both interfaces:

  • Extend i_network_component for common lifecycle methods
  • Use VoidResult return type for error handling consistency
  • Support observer pattern via connection_observer
  • Include comprehensive Doxygen documentation
  • Provide protocol-specific behavior notes

How

Implementation Highlights

  1. i_protocol_client Interface

    • Lifecycle: start(), stop(), is_connected()
    • Data transfer: send() with move semantics
    • Event handling: Observer pattern + legacy callbacks
    • Design: Protocol-agnostic with protocol-specific notes
  2. i_protocol_server Interface

    • Lifecycle: start(), stop(), connection_count()
    • Session management: Via i_session interface
    • Event handling: Connection, disconnection, receive, error callbacks
    • Design: Unified across TCP, UDP, HTTP, WebSocket, QUIC
  3. Documentation

    • Detailed Doxygen comments for all methods
    • Protocol-specific behavior notes (TCP vs UDP vs WebSocket)
    • Thread safety guarantees
    • Usage examples
    • Error condition documentation

Testing Done

  • Code compiles without errors
  • No warnings generated
  • All existing tests pass (build verification)
  • Interface-only change - no runtime tests required

Test Plan for Reviewers

  1. Verify compilation: cmake --build build --config Release
  2. Review interface design against existing i_client and i_server
  3. Check documentation completeness
  4. Confirm no breaking changes to existing code

Breaking Changes

None - This is an additive change. Existing code is not modified.
Protocols will be updated in subsequent PRs to implement these interfaces.

Next Steps

After this PR merges:

  1. Update TCP implementations to implement i_protocol_client/i_protocol_server
  2. Update UDP implementations
  3. Update WebSocket implementations
  4. Implement facade classes using these interfaces

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation added (comprehensive Doxygen)
  • No breaking changes
  • Compiles without warnings
  • Related issue linked with closing keywords

Introduce i_protocol_client and i_protocol_server interfaces
to establish common contracts across all protocol implementations
(TCP, UDP, HTTP, WebSocket, QUIC).

Features:
- Unified client lifecycle: start(), stop(), send(), is_connected()
- Unified server lifecycle: start(), stop(), connection_count()
- Observer pattern support via connection_observer
- Comprehensive documentation with protocol-specific notes
- Modern C++ design (VoidResult, std::string_view, move semantics)

Benefits:
- Eliminates code duplication across protocols
- Enables protocol-agnostic facade patterns
- Simplifies testing with consistent contracts
- Provides foundation for EPIC #577 facade implementation

Part of #577
@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Performance Comparison

Base Branch Results

No base results

PR Branch Results

No PR results

@kcenon kcenon merged commit 96f857f into main Feb 1, 2026
44 checks passed
@kcenon kcenon deleted the refactor/issue-593-create-protocol-interfaces branch February 1, 2026 11:43
kcenon added a commit that referenced this pull request Apr 13, 2026
Introduce i_protocol_client and i_protocol_server interfaces
to establish common contracts across all protocol implementations
(TCP, UDP, HTTP, WebSocket, QUIC).

Features:
- Unified client lifecycle: start(), stop(), send(), is_connected()
- Unified server lifecycle: start(), stop(), connection_count()
- Observer pattern support via connection_observer
- Comprehensive documentation with protocol-specific notes
- Modern C++ design (VoidResult, std::string_view, move semantics)

Benefits:
- Eliminates code duplication across protocols
- Enables protocol-agnostic facade patterns
- Simplifies testing with consistent contracts
- Provides foundation for EPIC #577 facade implementation

Part of #577
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.

refactor: Create common protocol interfaces (IProtocolClient, IProtocolServer)

1 participant