WebSocket for Unreal Engine
This is a draft integration guide for the Staxis WebSocket layer, not an engine-specific SDK. Start with the server-side echo path and the same versioned application message shape. Add player authentication and game-state authorization separately.
An Unreal Game Talking to a Staxis Service
For lobby updates, chat, or discrete backend commands, use an explicit application protocol over a WebSockets client. The Staxis echo endpoint can test the transport before game logic is involved. It does not implement Unreal replication or the Remote Control API.
{
"v": 1,
"action": "echo",
"requestId": "demo-1",
"data": { "text": "hello" }
}
Client Integration Flow
-
Use the WebSockets facilities for your Unreal version and create a client for the Staxis URL. Retain the client for the required game/session lifetime.
-
Bind connection, text-message, error, and close handling before Connect(). Send the JSON contract only after the connection is established.
-
For text, use the text message path and decode one complete JSON payload. For binary, define lengths and byte order and check the callback semantics for your engine version.
-
Keep received state changes synchronized with your game-thread flow. Bound pending actions, remove callbacks during teardown, and define how reconnect requests a fresh state snapshot.
Epic's IWebSocket reference describes Connect, Send, Close, and message/lifecycle events. Its raw-message event reference states that raw callbacks may occur multiple times for a message, and BytesRemaining refers to the current fragment. Do not equate a raw callback with a whole application message.
Server and Client Responsibilities
Use the server handler to check authentication, action permissions, payload shape, and game-state constraints. Add binary tags only as an application contract, following the binary example. Keep handshake Origin and extension behavior compatible with the selected native client; browser-hosted clients need the browser checks too.