Skip to content

[Merge with Minor version increment] feat: add version parsing and compatibility checks for server-client communication#301

Merged
from2001 merged 1 commit intodevelopfrom
feature/check-version-match
Jan 26, 2026
Merged

[Merge with Minor version increment] feat: add version parsing and compatibility checks for server-client communication#301
from2001 merged 1 commit intodevelopfrom
feature/check-version-match

Conversation

@from2001
Copy link
Collaborator

Version Check Feature

Overview

The version check ensures that the server and Unity client are running compatible protocol versions. It is performed once when a client first
connects to a room.

Protocol

The server includes its version (3 bytes: major, minor, patch) in the MSG_DEVICE_ID_MAPPING message:

[1 byte] Message Type (6)
[1 byte] Major Version ← Added
[1 byte] Minor Version ← Added
[1 byte] Patch Version ← Added
[2 bytes] Mapping Count
...

Compatibility Rules                                                                                                                           
┌───────────────────────────────────┬──────────────────────────────┐                                                                          
│             Condition             │            Result            │                                                                          
├───────────────────────────────────┼──────────────────────────────┤                                                                          
│ Major & Minor match               │ ✅ Compatible                │                                                                          
├───────────────────────────────────┼──────────────────────────────┤                                                                          
│ Patch mismatch only               │ ✅ Compatible                │                                                                          
├───────────────────────────────────┼──────────────────────────────┤                                                                          
│ Major or Minor mismatch           │ ❌ Incompatible → Disconnect │                                                                          
├───────────────────────────────────┼──────────────────────────────┤                                                                          
│ Either version is 0.0.x (unknown) │ ✅ Skip check                │                                                                          
└───────────────────────────────────┴──────────────────────────────┘                                                                          

Behavior on Mismatch

  1. Error logged: [NetSyncManager] Version mismatch! Server: x.y.z, Client: a.b.c. Disconnecting.
  2. OnVersionMismatch UnityEvent fires (for UI notification)
  3. Connection terminated via StopNetworking()

Public API

// NetSyncManager.cs
public UnityEvent<string, string> OnVersionMismatch;
// Parameters: (serverVersion, clientVersion) e.g., ("0.7.5", "0.8.0")

Limitations

If the protocol format itself changed incompatibly, the client's initial MSG_CLIENT_TRANSFORM may fail to parse on the server, preventing registration and ID mapping broadcast. In this case, the client will timeout rather than receive an explicit version mismatch error.

Close #50

@from2001 from2001 requested a review from Copilot January 25, 2026 08:25
@from2001 from2001 changed the title feat: add version parsing and compatibility checks for server-client communication [Merge with Minor version increment] feat: add version parsing and compatibility checks for server-client communication Jan 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds protocol version propagation and compatibility enforcement so Unity clients can detect incompatible server versions during the initial ID-mapping handshake and disconnect cleanly.

Changes:

  • Server now embeds its semantic version (major/minor/patch) into MSG_DEVICE_ID_MAPPING.
  • Server adds parse_version() and updates ID-mapping serialization to include the version bytes.
  • Unity adds a public OnVersionMismatch(serverVersion, clientVersion) event and disconnects on mismatch.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

File Description
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs Exposes OnVersionMismatch UnityEvent and disconnects when MessageProcessor reports incompatibility.
STYLY-NetSync-Server/src/styly_netsync/server.py Includes the server version in device-id mapping broadcasts.
STYLY-NetSync-Server/src/styly_netsync/binary_serializer.py Adds parse_version() and extends MSG_DEVICE_ID_MAPPING serialization to carry version bytes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@from2001 from2001 merged commit ad925c5 into develop Jan 26, 2026
7 checks passed
@from2001 from2001 deleted the feature/check-version-match branch January 26, 2026 11:37
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.

Check version match at handshake

2 participants