Skip to content

Add WebSocket server library - #5

Merged
SeanTAllen merged 1 commit into
mainfrom
sean/websocket-server-library
Feb 22, 2026
Merged

Add WebSocket server library#5
SeanTAllen merged 1 commit into
mainfrom
sean/websocket-server-library

Conversation

@SeanTAllen

Copy link
Copy Markdown
Member

Initial implementation of a WebSocket server library built on lori. Implements RFC 6455 including the HTTP upgrade handshake, frame parsing and encoding, message fragmentation/reassembly, and the close handshake.

Follows lori/stallion's "your actor IS the connection" pattern: users implement WebSocketServerActor and the library handles all protocol details, delivering application-level events through lifecycle callbacks.

Architecture:

  • WebSocketServer: protocol handler class (state machine, parsers, encoder)
  • WebSocketServerActor: trait combining TCPConnectionActor + lifecycle callbacks
  • Four-state machine: _Handshaking -> _Open -> _Closing -> _Closed
  • Internal components: handshake parser, frame parser/encoder, fragment reassembler, UTF-8 validator

60 unit tests including PonyCheck property-based tests for all internal components. WSS (TLS) support via WebSocketServer.ssl() constructor.

Design: #2

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Feb 22, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 22, 2026
Implements the WebSocket server library designed in Discussion #2,
built on lori (TCP) and ssl (SHA-1 for handshake accept key). Follows
lori/stallion's "your actor IS the connection" pattern where the user's
actor owns a WebSocketServer protocol handler instance.

Public API: WebSocketServer (protocol handler), WebSocketServerActor
(user trait), WebSocketLifecycleEventReceiver (callbacks with default
no-ops), WebSocketConfig (immutable config), UpgradeRequest (parsed
HTTP upgrade), CloseCode and HandshakeError unions.

Internal components: _HandshakeParser (HTTP upgrade), _FrameParser
(incremental WebSocket frame parsing), _FrameEncoder (server frames),
_FragmentReassembler (message reassembly with UTF-8 validation),
_Utf8Validator, and a trait-based state machine (_Handshaking, _Open,
_Closing, _Closed).

60 tests (example-based + PonyCheck property tests) covering all
parsers, encoder, reassembler, and validator. Echo server example.

Design: #2
@SeanTAllen
SeanTAllen force-pushed the sean/websocket-server-library branch from 0536cb8 to c3c5c76 Compare February 22, 2026 22:57
@SeanTAllen
SeanTAllen merged commit 290c9e4 into main Feb 22, 2026
2 checks passed
@SeanTAllen
SeanTAllen deleted the sean/websocket-server-library branch February 22, 2026 22:57
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 22, 2026
github-actions Bot pushed a commit that referenced this pull request Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - added Automatically add "Added" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants