Skip to content

PhoenixSharp 2.0.0 — The Hardening Release

Latest

Choose a tag to compare

@Mazyod Mazyod released this 25 Jul 12:42
· 7 commits to master since this release
Immutable release. Only release title and notes can be modified.

PhoenixSharp 2.0 is a ground-up hardening of the 1.x library: 29 commits closing every finding from a full-library audit, with the test suite growing from 220 to 375 tests, every behavioral change test-driven, and every commit adversarially reviewed before merge.

Highlights

  • Full thread safety. All core state (socket lifecycle, push reply pipeline, heartbeats, presence, schedulers, callback registration) is now properly synchronized with documented semantics. Callbacks may fire on any thread — see the new Threading model section.
  • No await-forever paths. ConnectAsync, DisconnectAsync, JoinAsync, PushAsync, LeaveAsync, and the wait helpers complete (or fault with typed exceptions) in every reachable state — including disposal, mid-reconnect disconnects, custom server reply statuses, and throwing user callbacks.
  • Structured errors, visible by default. Typed exceptions (PhoenixConnectionException, InvalidOperationException for misuse), a structured PhoenixError on OnError, a new OnUnhandledError surface for contained failures, a redesigned ILogger with sink-owned filtering, and shipped ConsoleLogger/UnityLogger implementations. Silent failure is gone.
  • Resilient send policy. Send failures are contained and retried with an attempt cap — they no longer error channels, reset reconnect backoff, or fault connect waiters. Serializer failures are dropped poison; heartbeats are send-or-drop.
  • Protocol tolerance. Custom reply statuses no longer break the reply pipeline; connection params are URL-encoded (base64 tokens work); V2 frames are validated; Options.ParamsProvider enables fresh auth tokens on every reconnect.
  • Mobile performance. Steady-state dispatch allocations cut from 184 to 56 bytes/message (replies 288 → 104); presence sync 27% less garbage and 33% faster; cancelled timers release immediately. Allocation budgets are enforced by tests.
  • Packaging. XML IntelliSense docs and SourceLink now ship in the NuGet package; the Unity package gains an engine-free core assembly with a separate auto-referenced Phoenix.UnityLogger assembly, and CI now compile-gates both Unity assembly shapes.

Breaking changes

2.0 is a breaking release. The Migration Guide covers every change with before/after snippets — the headline items:

  • ILogger is a new two-method interface (IsEnabled + Log with an Exception? parameter)
  • Socket.OnError delivers a PhoenixError instead of a string; Socket/Presence callback members are now C# events
  • WebsocketConfiguration is an immutable class with PascalCase properties; the IWebsocket contract is documented
  • Presence.State is a get-only snapshot property; presence callbacks match phoenix.js semantics exactly
  • Send/serialization failures surface through OnError instead of throwing synchronously
  • Connection params are snapshotted at construction and escaped exactly once (use ParamsProvider for live token refresh)

Upgrading

  1. Read the Migration Guide — compile-time breaks first, then runtime behavior changes.
  2. Unity consumers: the recommended NativeWebSocket adapter sample now requires NativeWebSocket 2.x and Tick() must be called every frame (see the sample's notes on why).

Built with test-driven development and multi-agent adversarial review. Implementation by OpenAI Codex; orchestration and review by Claude.