mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
breaking: remove NetworkConnection.InvokeHandler now that it's not needed anymore
This commit is contained in:
parent
be42976a26
commit
4c12c59f78
@ -185,42 +185,6 @@ internal void RemoveObservers()
|
||||
visList.Clear();
|
||||
}
|
||||
|
||||
internal bool InvokeHandler(int msgType, NetworkReader reader, int channelId)
|
||||
{
|
||||
if (messageHandlers.TryGetValue(msgType, out NetworkMessageDelegate msgDelegate))
|
||||
{
|
||||
msgDelegate(this, reader, channelId);
|
||||
return true;
|
||||
}
|
||||
if (logger.LogEnabled()) logger.Log("Unknown message ID " + msgType + " " + this + ". May be due to no existing RegisterHandler for this message.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function invokes the registered handler function for a message.
|
||||
/// <para>Network connections used by the NetworkClient and NetworkServer use this function for handling network messages.</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The message type to unregister.</typeparam>
|
||||
/// <param name="msg">The message object to process.</param>
|
||||
/// <returns>Returns true if the handler was successfully invoked</returns>
|
||||
public bool InvokeHandler<T>(T msg, int channelId)
|
||||
where T : struct, NetworkMessage
|
||||
{
|
||||
using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter())
|
||||
{
|
||||
// if it is a value type, just use typeof(T) to avoid boxing
|
||||
// this works because value types cannot be derived
|
||||
// if it is a reference type (for example NetworkMessage),
|
||||
// ask the message for the real type
|
||||
int msgType = MessagePacker.GetId<T>();
|
||||
|
||||
MessagePacker.Pack(msg, writer);
|
||||
ArraySegment<byte> segment = writer.ToArraySegment();
|
||||
using (PooledNetworkReader networkReader = NetworkReaderPool.GetReader(segment))
|
||||
return InvokeHandler(msgType, networkReader, channelId);
|
||||
}
|
||||
}
|
||||
|
||||
// helper function
|
||||
protected bool UnpackAndInvoke(NetworkReader reader, int channelId)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user