Skip to content

Implement Websockets#86

Open
sorokya wants to merge 1 commit intoethanmoffat:masterfrom
sorokya:websockets
Open

Implement Websockets#86
sorokya wants to merge 1 commit intoethanmoffat:masterfrom
sorokya:websockets

Conversation

@sorokya
Copy link
Copy Markdown
Contributor

@sorokya sorokya commented Mar 26, 2026

Add optional WebSocket listener on a configurable port (WebSocketPort = 0 to disable). WebSocket clients connect on the separate port, complete the HTTP 101 upgrade handshake, then are processed identically to TCP clients for the EO binary protocol.

Implementation details:

  • src/websocket.hpp: new header with SHA-1, base64, and WebSocket frame encode/decode utilities (no external dependencies)
  • EOServer: second listener socket (ws_listen_sock_) initialized in Initialize() when WebSocketPort > 0; PollWebSocket() called from Tick() applies same IP rate-limiting as regular TCP connections
  • EOClient: websocket_ flag + DoWsHandshake(), DecodeWsFrames(), WsRecv() methods; Tick() handles HTTP upgrade and WS frame decoding transparently; Send() wraps outgoing EO packets in binary WS frames; file uploads send each chunk as a WS frame; NeedTick() returns true while decoded payload remains unprocessed
  • config/server.ini: WebSocketPort = 0 (disabled by default)
  • src/eoserv_config.cpp: default for WebSocketPort = 0
  • src/main.cpp: log WS listener port at startup

I DIDN'T REVIEW THIS AT ALL YET

image

Add optional WebSocket listener on a configurable port (WebSocketPort = 0
to disable). WebSocket clients connect on the separate port, complete the
HTTP 101 upgrade handshake, then are processed identically to TCP clients
for the EO binary protocol.

Implementation details:
- src/websocket.hpp: new header with SHA-1, base64, and WebSocket frame
  encode/decode utilities (no external dependencies)
- EOServer: second listener socket (ws_listen_sock_) initialized in
  Initialize() when WebSocketPort > 0; PollWebSocket() called from
  Tick() applies same IP rate-limiting as regular TCP connections
- EOClient: websocket_ flag + DoWsHandshake(), DecodeWsFrames(), WsRecv()
  methods; Tick() handles HTTP upgrade and WS frame decoding transparently;
  Send() wraps outgoing EO packets in binary WS frames; file uploads send
  each chunk as a WS frame; NeedTick() returns true while decoded payload
  remains unprocessed
- config/server.ini: WebSocketPort = 0 (disabled by default)
- src/eoserv_config.cpp: default for WebSocketPort = 0
- src/main.cpp: log WS listener port at startup
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.

1 participant