All notable changes to this project are documented in this file.
This changelog starts at 2.0.5 — see the GitHub Releases page for earlier versions.
-
Queued events and messages are now delivered in arrival order.
DispatchMessageQueue()drained the message queue first and a separate event queue afterwards, so an event queued before a batch of messages was delivered after them.OnOpenin particular arrived after the first messages had already been handed to the consumer, so anything gating on it — such as Colyseus'Connection.IsOpen— still looked closed while messages were being processed, and calls guarded by it silently did nothing.Events now record their position as a
nullplaceholder in the message queue, with the actions in a side queue; both are appended under the same lock, so anullentry always has an event waiting for it.This only affected consumers without a
SynchronizationContext— MonoGame, console apps and test hosts. With one present (as in Unity) events are posted directly and were already ordered correctly. Regression introduced in 2.0.1.
2.0.6 was never published — its release workflow was stranded by a GitHub Actions outage and could not be re-queued, so this content ships as 2.0.7.
-
Close codes outside the enum are no longer reported as
1004.WebSocketHelpers.ParseCloseCodeEnum()collapsed every code without a matchingWebSocketCloseCodemember intoWebSocketCloseCode.Undefined(1004), so application close codes (RFC 6455 reserves 3000-4999 for applications) were indistinguishable from one another. Any valid close code (1000-4999) is now preserved as-is. -
The closing handshake now echoes the code the server sent. When a close frame arrived, the receive loop called
Close()— which short-circuits on itsState == Opencheck, because a socket that just received a close frame is inCloseReceived. The result was that no closing handshake response was ever sent, and had it been, it would have carriedNormal(1000) rather than the received code. Servers read their own close code from that response, so a deliberate close looked to them like a dropped connection (1006). The response is now sent viaCloseOutputAsyncwith the received code.Together these fixes resolve colyseus/colyseus#948, where a server-side
client.leave(4000)(Colyseus'CloseCode.CONSENTED) surfaced on the client as close code 1004, and made the server runonDrop()— opening a reconnection window — instead of treating the leave as consented. Thanks to @trueicecold for the detailed report.
-
Renamed the Unity WebGL plugin files from
WebSocket.jslib/WebSocket.jspretoNativeWebSocket.jslib/NativeWebSocket.jspre. Unity flattens WebGL plugins into a single output directory, so the previous generic name collided with identically named plugins from other packages (Photon ships aWebSocket.jslib), failing the build withPlugin 'WebSocket.jslib' is used from several locations. Only the file names changed — the exported JavaScript symbols are unchanged, and nothing references these files by name. Thanks to @Alaadel for reporting.Upgrading:
.unitypackageimports do not delete removed files. If you upgrade in place, delete the oldWebSocket.jslibandWebSocket.jsprefrom your project, otherwise the new and old plugins will collide with each other. Users installing via UPM are not affected.