empty message handlers

This commit is contained in:
mischa 2024-09-05 14:40:08 +02:00
parent 32b784376d
commit 9d4a470449
2 changed files with 14 additions and 0 deletions

View File

@ -511,6 +511,7 @@ internal static void RegisterMessageHandlers(bool hostMode)
RegisterHandler<ObjectSpawnFinishedMessage>(_ => { });
// host mode doesn't need state updates
RegisterHandler<EntityStateMessage>(_ => { });
RegisterHandler<EntityStateMessageUnreliable>(_ => { });
}
else
{
@ -522,6 +523,7 @@ internal static void RegisterMessageHandlers(bool hostMode)
RegisterHandler<ObjectSpawnStartedMessage>(OnObjectSpawnStarted);
RegisterHandler<ObjectSpawnFinishedMessage>(OnObjectSpawnFinished);
RegisterHandler<EntityStateMessage>(OnEntityStateMessage);
RegisterHandler<EntityStateMessageUnreliable>(OnEntityStateMessageUnreliable);
}
// These handlers are the same for host and remote clients
@ -1440,6 +1442,11 @@ static void OnEntityStateMessage(EntityStateMessage message)
else Debug.LogWarning($"Did not find target for sync message for {message.netId}. Were all prefabs added to the NetworkManager's spawnable list?\nNote: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.");
}
static void OnEntityStateMessageUnreliable(EntityStateMessageUnreliable message, int channelId)
{
throw new NotImplementedException();
}
static void OnRPCMessage(RpcMessage message)
{
// Debug.Log($"NetworkClient.OnRPCMessage hash:{message.functionHash} netId:{message.netId}");

View File

@ -318,6 +318,7 @@ internal static void RegisterMessageHandlers()
RegisterHandler<NetworkPingMessage>(NetworkTime.OnServerPing, false);
RegisterHandler<NetworkPongMessage>(NetworkTime.OnServerPong, false);
RegisterHandler<EntityStateMessage>(OnEntityStateMessage, true);
RegisterHandler<EntityStateMessageUnreliable>(OnEntityStateMessageUnreliable, true);
RegisterHandler<TimeSnapshotMessage>(OnTimeSnapshotMessage, false); // unreliable may arrive before reliable authority went through
}
@ -429,6 +430,12 @@ static void OnEntityStateMessage(NetworkConnectionToClient connection, EntitySta
// else Debug.LogWarning($"Did not find target for sync message for {message.netId} . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.");
}
// for client's owned ClientToServer components.
static void OnEntityStateMessageUnreliable(NetworkConnectionToClient connection, EntityStateMessageUnreliable message, int channelId)
{
throw new NotImplementedException();
}
// client sends TimeSnapshotMessage every sendInterval.
// batching already includes the remoteTimestamp.
// we simply insert it on-message here.