Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: session state token #3228

Draft
wants to merge 4 commits into
base: develop-2.0.0
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade

internal struct ConnectionApprovedMessage : INetworkMessage
{
private const int k_AddSessionStateToken = 3;
private const int k_AddCMBServiceConfig = 2;
private const int k_VersionAddClientIds = 1;
public int Version => k_AddCMBServiceConfig;
public int Version => k_AddSessionStateToken;

public ulong OwnerClientId;
public ulong SessionStateToken;
public int NetworkTick;
// The cloud state service should set this if we are restoring a session
public ServiceConfig ServiceConfig;
Expand Down Expand Up @@ -108,6 +110,10 @@ public void Serialize(FastBufferWriter writer, int targetVersion)
// ============================================================

BytePacker.WriteValueBitPacked(writer, OwnerClientId);
if (targetVersion >= k_AddSessionStateToken)
{
writer.WriteValueSafe(SessionStateToken);
}
BytePacker.WriteValueBitPacked(writer, NetworkTick);
if (IsDistributedAuthority)
{
Expand Down Expand Up @@ -199,6 +205,10 @@ public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int
// ============================================================
m_ReceiveMessageVersion = receivedMessageVersion;
ByteUnpacker.ReadValueBitPacked(reader, out OwnerClientId);
if (receivedMessageVersion >= k_AddSessionStateToken)
{
reader.ReadValueSafe(out SessionStateToken);
}
ByteUnpacker.ReadValueBitPacked(reader, out NetworkTick);
if (networkManager.DistributedAuthorityMode)
{
Expand Down