Skip to content

Commit 53b94ca

Browse files
authored
feat: session state token (#3228)
https://jira.unity3d.com/browse/MTT-10043 https://docs.google.com/document/d/1st5PoxRa7rg5JsLW0pKbVAgaqBP1QdUCx2gFlHXEicg/edit?tab=t.0 Adding a SessionStateToken to the ConnectionApproved message and incrementing the version. This is safe without implementing the feature as the service does not need to make any assumptions about what the client does with this information. ## Changelog - Added: Session State Token into the ConnectionApproved message ## Testing and Documentation - Tested using E2E tests and existing tests ## Related PR Unity-Technologies/mps-common-multiplayer-backend#976
1 parent bb0566c commit 53b94ca

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

com.unity.netcode.gameobjects/Runtime/Configuration/SessionConfig.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ internal class SessionConfig
88
public const uint NoFeatureCompatibility = 0;
99
public const uint BypassFeatureCompatible = 1;
1010
public const uint ServerDistributionCompatible = 2;
11+
public const uint SessionStateToken = 3;
1112

1213
// The most current session version (!!!!set this when you increment!!!!!)
13-
public static uint PackageSessionVersion => ServerDistributionCompatible;
14+
public static uint PackageSessionVersion => SessionStateToken;
1415

1516
internal uint SessionVersion;
1617

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ internal struct ServiceConfig : INetworkSerializable
99
public bool IsRestoredSession;
1010
public ulong CurrentSessionOwner;
1111
public bool ServerRedistribution;
12+
public ulong SessionStateToken;
1213

1314
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
1415
{
@@ -22,6 +23,11 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
2223
{
2324
serializer.SerializeValue(ref ServerRedistribution);
2425
}
26+
27+
if (SessionVersion >= SessionConfig.SessionStateToken)
28+
{
29+
serializer.SerializeValue(ref SessionStateToken);
30+
}
2531
}
2632
else
2733
{
@@ -37,6 +43,15 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
3743
{
3844
ServerRedistribution = false;
3945
}
46+
47+
if (SessionVersion >= SessionConfig.SessionStateToken)
48+
{
49+
serializer.SerializeValue(ref SessionStateToken);
50+
}
51+
else
52+
{
53+
SessionStateToken = 0;
54+
}
4055
}
4156
}
4257
}

0 commit comments

Comments
 (0)