Skip to content

Latest commit

Β 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SimpleChatBox

.NET Framework 4.8 Dependencies Platform Tests Architecture License

SimpleChatBox is a high-performance, enterprise-grade real-time chat and multimedia communication platform built on C# Windows Forms and .NET Framework 4.8. It operates with zero external NuGet package dependencies, relying solely on native .NET Base Class Libraries (BCL).

The platform showcases robust software engineering patterns: length-prefixed TCP binary framing, ECDH shared secret negotiation, AES-256-CBC end-to-end encryption, STUN NAT traversal with UDP hole punching, server relay fallback, pluggable synthetic camera video capture, desktop screen sharing, a live telemetry server dashboard, and an automated regression test suite.


πŸ“Έ Interface Showcase

Real-Time Chat & Direct Messaging P2P Video Call & Synthetic Camera HUD
Real-Time Chat Video Call HUD
Server Management & Telemetry Console 1-Click Demo Authentication
Server Dashboard Login Screen

🌟 Key Capabilities

1. Pluggable Video Streaming Pipeline (P2P & Relay)

  • Zero Webcam Hardware Required: Features an embedded high-performance Synthetic Camera (SyntheticVideoSource) that generates animated radar sweeps, live millisecond clocks, dynamic audio frequency bars, and user identity badges at 15–20 FPS.
  • Desktop Screen Sharing: Includes ScreenCaptureVideoSource to capture and stream the active desktop display in real-time.
  • Picture-in-Picture (PIP) & Camera Switch: Local preview window rendered simultaneously over remote incoming streams with memory-safe GDI bitmap recycling.
  • STUN NAT Traversal (RFC 5389): Discovers public IP endpoints and initiates UDP hole punching for direct peer-to-peer streaming.
  • Automatic Server Relay Fallback: Seamlessly falls back to TCP server relay when UDP hole punching is blocked by symmetric NATs or restrictive firewalls.

2. End-to-End Cryptography & Security

  • ECDH Key Exchange: Implements Diffie-Hellman Elliptic Curve Key Exchange (DiffieHellmanHelper) for per-session shared secret negotiation.
  • AES-256-CBC Encryption: End-to-end encrypted messaging with dynamically generated initialization vectors (IVs).
  • Secure Authentication: SHA-256 hashed password storage (UserStore) with pre-seeded demo credentials.

3. Server Management & Real-Time Telemetry Dashboard

  • Live Client Directory: ListView displaying client IDs, usernames, display names, IP endpoints, connection timestamps, and packet counters.
  • Administrative Controls: Right-click context menu to disconnect/kick connected clients.
  • Real-Time HUD: Live uptime clock, total routed message counters, and host IP address display for LAN discovery.
  • One-Click Multi-Client Launch: Dedicated button to automatically spin up 2 demo client instances (alice and bob).

4. Client UX & Quick Demo Workflow

  • 1-Click Demo Login: Quick-access buttons for pre-seeded users (πŸ‘€ Alice, πŸ‘€ Bob, πŸ‘€ Charlie).
  • CLI Automation: Supports command-line auto-login arguments (e.g., ChatBox.Client.exe demo_alice).
  • File Transfer Progress: Real-time chunk transmission progress (cur/total chunks and percentage indicator).
  • Dedicated Image Previewer: Modal dialog (frmImagePreview) for viewing received .jpg, .png, .gif, and .bmp files with image dimensions, file size, and explorer shortcuts.
  • Tabbed Chat Interface: Dynamic tabs for the public general room and private 1-on-1 conversations with unread indicators.

5. Automated Regression Test Suite (ChatBox.Tests)

  • Custom lightweight test runner with zero third-party dependencies verifying:
    1. Packet serialization, length-prefixed framing, and UTF-8 encoding.
    2. AES-256 encryption/decryption roundtrips and ECDH shared key equivalence.
    3. User authentication, password hashing, and message history persistence.
    4. Video generator frame capture, synthetic radar animation, and JPEG SOI header validity.
    5. STUN packet construction and attribute parsing.
    6. Large file chunking, reassembly, and SHA-256 payload integrity.
    7. Cryptographic invariants (random IV uniqueness and tamper resistance).
    8. Floating PIP geometry and boundary clipping.

πŸ›οΈ System Architecture

ChatBoxSimple.sln
β”‚
β”œβ”€β”€ ChatBox.Shared/               # Core BCL Library (Shared across Server & Client)
β”‚   β”œβ”€β”€ Constants/AppConstants.cs # Protocol ports, buffer limits, chunk sizes
β”‚   β”œβ”€β”€ Crypto/                   # AES-256-CBC & Diffie-Hellman (ECDH) helpers
β”‚   β”œβ”€β”€ DTOs/                     # Network data transfer contracts
β”‚   β”œβ”€β”€ Network/StunClient.cs     # RFC 5389 STUN NAT traversal engine
β”‚   └── Protocol/                 # Packet framing, packet types, and JSON serialization
β”‚
β”œβ”€β”€ ChatBox.Server/               # WinForms Server Management Host
β”‚   β”œβ”€β”€ Data/                     # UserStore (JSON) & MessageStore (JSON history)
β”‚   β”œβ”€β”€ Models/                   # ConnectedClient & UserAccount
β”‚   β”œβ”€β”€ Services/                 # TcpServerService, AuthService, MessageRouter
β”‚   └── Forms/frmServer.cs        # Telemetry HUD, Client list, and 1-click launcher
β”‚
β”œβ”€β”€ ChatBox.Client/               # WinForms End-User Client
β”‚   β”œβ”€β”€ Forms/                    # frmLogin, frmChat, frmVideoCall, frmImagePreview
β”‚   β”œβ”€β”€ Helpers/VideoRecorder.cs  # Video call recording hooks
β”‚   └── Services/                 # Pluggable IVideoSource, VideoCallService,
β”‚                                 # FileTransferService, FileReceiveService, UdpPeerService
β”‚
└── ChatBox.Tests/                # Standalone Automated Test Runner (.NET 4.8)
    β”œβ”€β”€ Program.cs                # Test harness entry point (exit code 0/1)
    β”œβ”€β”€ ProtocolTests.cs          # Serialization and packet integrity tests
    β”œβ”€β”€ CryptoTests.cs            # Cryptographic roundtrip & invariant tests
    β”œβ”€β”€ StorageTests.cs           # Database and persistence tests
    β”œβ”€β”€ VideoSourceTests.cs       # Video frame generation, compression & PIP tests
    β”œβ”€β”€ StunTests.cs              # RFC 5389 STUN protocol tests
    β”œβ”€β”€ FileTransferTests.cs      # Chunking and reassembly tests
    └── DemoScreenshotGenerator.cs# High-resolution screenshot generator for documentation

πŸ“Ή Video Call Flow Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Client A                  Server               Client B β”‚
β”‚      β”‚                        β”‚                    β”‚     β”‚
β”‚      β”œβ”€β”€STUN Discovery───────→│                    β”‚     β”‚
β”‚      β”‚  (Public IP/Port)      β”‚                    β”‚     β”‚
β”‚      β”‚                        β”‚                    β”‚     β”‚
β”‚      β”œβ”€β”€VideoCallRequest─────→│───Forward Signal──→│     β”‚
β”‚      β”‚                        β”‚     ←──Accept───────     β”‚
β”‚      β”‚   ←──Forward Signal─────                    β”‚     β”‚
β”‚      β”‚                                             β”‚     β”‚
β”‚      β”œβ•β•β•β•β•β•β•β•β•β•β•β• UDP Hole Punching ══════════════─     β”‚
β”‚      β”‚                                             β”‚     β”‚
β”‚      β”‚  [Success] β†’ Direct P2P UDP Streaming       β”‚     β”‚
β”‚      β”‚  [Failure] β†’ Fallback TCP Server Relay      β”‚     β”‚
β”‚      β”‚                                             β”‚     β”‚
β”‚      └──Display Local PIP (Synthetic/Screen Share)β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ‘₯ Default Demo Accounts

All demo accounts are pre-seeded in UserStore with password 123:

Username Password Display Name Role
alice 123 Alice Johnson Demo User A
bob 123 Bob Williams Demo User B
charlie 123 Charlie Davis Demo User C

πŸš€ Quick Start Guide

Prerequisites

  • Operating System: Windows 10 / 11 / Windows Server 2016+
  • Runtime: .NET Framework 4.8 runtime (pre-installed on modern Windows)
  • Build Tools: .NET SDK (dotnet build) or Visual Studio 2022 / MSBuild

Automated 1-Command Demo Launcher

Run the PowerShell orchestrator script from the repository root:

powershell -ExecutionPolicy Bypass -File .\scripts\run-demo.ps1

This script automatically:

  1. Compiles the solution in Debug configuration.
  2. Executes the regression test suite (ChatBox.Tests.exe).
  3. Starts the Server Dashboard and binds to port 9000.
  4. Spawns two pre-configured demo clients (Alice and Bob) with automatic login.

Manual Execution Steps

1. Compile the Solution

dotnet build ChatBoxSimple.sln -c Debug

2. Run the Test Suite

.\ChatBox.Tests\bin\Debug\ChatBox.Tests.exe

3. Start the Server

.\ChatBox.Server\bin\Debug\ChatBox.Server.exe
  • Click β–Ά Start to bind port 9000.
  • Click ⚑ Launch 2 Demo Clients to launch both Alice and Bob simultaneously.

4. Start the Clients

.\ChatBox.Client\bin\Debug\ChatBox.Client.exe demo_alice
.\ChatBox.Client\bin\Debug\ChatBox.Client.exe demo_bob

Alternatively, launch ChatBox.Client.exe and click πŸ‘€ Alice or πŸ‘€ Bob on the login screen for instant 1-click access.


πŸ“¦ Build & Release Packaging (scripts/publish-app.ps1)

In adherence with enterprise deployment standards, the project supports both distribution modes:

# Full release package (includes binaries, assets, and debug symbols):
powershell -ExecutionPolicy Bypass -File .\scripts\publish-app.ps1 -Mode Full

# Lite release package (optimized standalone binaries, excludes .pdb symbols):
powershell -ExecutionPolicy Bypass -File .\scripts\publish-app.ps1 -Mode Lite

Generated outputs are placed in publish/Full and publish/Lite, along with redistributable zip archives SimpleChatBox-v1.1.0-Full.zip and SimpleChatBox-v1.1.0-Lite.zip.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

High-performance real-time chat & multimedia platform on C# WinForms (.NET 4.8) with zero dependencies. Features P2P video, synthetic camera HUD, screen sharing, STUN NAT traversal, ECDH/AES-256 E2EE, and live telemetry.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages