public void RegisterHandler(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterHandler id:" + (object)msgType + " handler is null")); } else if ((int)msgType <= 31) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterHandler: Cannot replace system message handler " + (object)msgType)); } else { if (this.m_MsgHandlers.ContainsKey(msgType)) { if (LogFilter.logDebug) { Debug.Log((object)("RegisterHandler replacing " + (object)msgType)); } this.m_MsgHandlers.Remove(msgType); } if (LogFilter.logDebug) { Debug.Log((object)("RegisterHandler id:" + (object)msgType + " handler:" + handler.Method.Name)); } this.m_MsgHandlers.Add(msgType, handler); } }
public void RegisterHandler(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (LogFilter.logError) { Debug.LogError("RegisterHandler id:" + msgType + " handler is null"); } return; } if (msgType <= 31) { if (LogFilter.logError) { Debug.LogError("RegisterHandler: Cannot replace system message handler " + msgType); } return; } if (m_MsgHandlers.ContainsKey(msgType)) { if (LogFilter.logDebug) { Debug.Log("RegisterHandler replacing " + msgType); } m_MsgHandlers.Remove(msgType); } if (LogFilter.logDebug) { Debug.Log("RegisterHandler id:" + msgType + " handler:" + handler.Method.Name); } m_MsgHandlers.Add(msgType, handler); }
private void GenerateError(int error) { NetworkMessageDelegate handler = this.m_MessageHandlers.GetHandler(34); if (handler == null) { handler = this.m_MessageHandlers.GetHandler(34); } if (handler != null) { ErrorMessage errorMessage = new ErrorMessage(); errorMessage.errorCode = error; byte[] buffer = new byte[200]; NetworkWriter writer = new NetworkWriter(buffer); errorMessage.Serialize(writer); NetworkReader reader = new NetworkReader(buffer); handler(new NetworkMessage { msgType = 34, reader = reader, conn = this.m_Connection, channelId = 0 }); } }
private void GenerateError(int error) { NetworkMessageDelegate networkMessageDelegate = this.m_MessageHandlers.GetHandler((short)34) ?? this.m_MessageHandlers.GetHandler((short)34); if (networkMessageDelegate == null) { return; } ErrorMessage errorMessage = new ErrorMessage(); errorMessage.errorCode = error; byte[] buffer = new byte[200]; NetworkWriter writer = new NetworkWriter(buffer); errorMessage.Serialize(writer); NetworkReader networkReader = new NetworkReader(buffer); networkMessageDelegate(new NetworkMessage() { msgType = (short)34, reader = networkReader, conn = this.m_Connection, channelId = 0 }); }
public void RegisterHandler(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (LogFilter.logError) { Debug.LogError("RegisterHandler id:" + msgType + " handler is null"); } } else if (msgType <= 0x1f) { if (LogFilter.logError) { Debug.LogError("RegisterHandler: Cannot replace system message handler " + msgType); } } else { if (this.m_MsgHandlers.ContainsKey(msgType)) { if (LogFilter.logDebug) { Debug.Log("RegisterHandler replacing " + msgType); } this.m_MsgHandlers.Remove(msgType); } if (LogFilter.logDebug) { Debug.Log(string.Concat(new object[] { "RegisterHandler id:", msgType, " handler:", handler.Method.Name })); } this.m_MsgHandlers.Add(msgType, handler); } }
public bool InvokeHandler(short msgType, NetworkReader reader, int channelId) { bool result; if (this.m_MessageHandlersDict.ContainsKey(msgType)) { this.m_MessageInfo.msgType = msgType; this.m_MessageInfo.conn = this; this.m_MessageInfo.reader = reader; this.m_MessageInfo.channelId = channelId; NetworkMessageDelegate networkMessageDelegate = this.m_MessageHandlersDict[msgType]; if (networkMessageDelegate == null) { if (LogFilter.logError) { Debug.LogError("NetworkConnection InvokeHandler no handler for " + msgType); } result = false; } else { networkMessageDelegate(this.m_MessageInfo); result = true; } } else { result = false; } return(result); }
internal void RegisterHandlerSafe(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (LogFilter.logError) { Debug.LogError("RegisterHandlerSafe id:" + msgType + " handler is null"); } return; } if (LogFilter.logDebug) { Debug.Log(string.Concat(new object[] { "RegisterHandlerSafe id:", msgType, " handler:", handler.Method.Name })); } if (this.m_MsgHandlers.ContainsKey(msgType)) { return; } this.m_MsgHandlers.Add(msgType, handler); }
void GenerateError(int error) { NetworkMessageDelegate msgDelegate = m_MessageHandlers.GetHandler(MsgType.Error); if (msgDelegate == null) { msgDelegate = m_MessageHandlers.GetHandler(MsgType.Error); } if (msgDelegate != null) { ErrorMessage msg = new ErrorMessage(); msg.errorCode = error; // write the message to a local buffer byte[] errorBuffer = new byte[200]; NetworkWriter writer = new NetworkWriter(errorBuffer); msg.Serialize(writer); // pass a reader (attached to local buffer) to handler NetworkReader reader = new NetworkReader(errorBuffer); NetworkMessage netMsg = new NetworkMessage(); netMsg.msgType = MsgType.Error; netMsg.reader = reader; netMsg.conn = m_Connection; netMsg.channelId = 0; msgDelegate(netMsg); } }
protected void HandleReader(NetworkReader reader, int receivedSize, int channelId) { while ((ulong)reader.Position < (ulong)((long)receivedSize)) { ushort num = reader.ReadUInt16(); short num2 = reader.ReadInt16(); byte[] array = reader.ReadBytes((int)num); NetworkReader reader2 = new NetworkReader(array); if (this.logNetworkMessages) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < (int)num; i++) { stringBuilder.AppendFormat("{0:X2}", array[i]); if (i > 150) { break; } } Debug.Log(string.Concat(new object[] { "ConnectionRecv con:", this.connectionId, " bytes:", num, " msgId:", num2, " ", stringBuilder })); } NetworkMessageDelegate networkMessageDelegate = null; if (this.m_MessageHandlersDict.ContainsKey(num2)) { networkMessageDelegate = this.m_MessageHandlersDict[num2]; } if (networkMessageDelegate == null) { if (LogFilter.logError) { Debug.LogError(string.Concat(new object[] { "Unknown message ID ", num2, " connId:", this.connectionId })); } break; } this.m_NetMsg.msgType = num2; this.m_NetMsg.reader = reader2; this.m_NetMsg.conn = this; this.m_NetMsg.channelId = channelId; networkMessageDelegate(this.m_NetMsg); this.lastMessageTime = Time.time; } }
public bool InvokeHandler(NetworkMessage netMsg) { if (m_MessageHandlersDict.ContainsKey(netMsg.msgType)) { NetworkMessageDelegate msgDelegate = m_MessageHandlersDict[netMsg.msgType]; msgDelegate(netMsg); return(true); } return(false); }
/// <summary> /// <para>This function invokes the registered handler function for a message.</para> /// </summary> /// <param name="msgType">The message type of the handler to use.</param> /// <param name="reader">The stream to read the contents of the message from.</param> /// <param name="channelId">The channel that the message arrived on.</param> /// <param name="netMsg">The message object to process.</param> /// <returns> /// <para>True if a handler function was found and invoked.</para> /// </returns> public bool InvokeHandler(NetworkMessage netMsg) { if (this.m_MessageHandlersDict.ContainsKey(netMsg.msgType)) { NetworkMessageDelegate delegate2 = this.m_MessageHandlersDict[netMsg.msgType]; delegate2(netMsg); return(true); } return(false); }
public void RegisterHandler(short msgType, NetworkMessageDelegate handler) { if (m_MessageHandlers.ContainsKey(msgType)) { if (LogFilter.logDebug) { Debug.Log("NetworkConnection.RegisterHandler replacing " + msgType); } } m_MessageHandlers[msgType] = handler; }
internal void RegisterSystemHandlers(bool localClient) { ClientScene.RegisterSystemHandlers(this, localClient); this.RegisterHandlerSafe(14, new NetworkMessageDelegate(this.OnCRC)); short msgType = 17; if (NetworkClient.< > f__mg$cache1 == null) { NetworkClient.< > f__mg$cache1 = new NetworkMessageDelegate(NetworkConnection.OnFragment); } this.RegisterHandlerSafe(msgType, NetworkClient.< > f__mg$cache1); }
protected void HandleReader(NetworkReader reader, int receivedSize, int channelId) { short num2; while (true) { if (reader.Position >= receivedSize) { return; } ushort num = reader.ReadUInt16(); num2 = reader.ReadInt16(); byte[] array = reader.ReadBytes(num); NetworkReader reader2 = new NetworkReader(array); if (logNetworkMessages) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < num; i++) { stringBuilder.AppendFormat("{0:X2}", array[i]); if (i > 150) { break; } } Debug.Log("ConnectionRecv con:" + connectionId + " bytes:" + num + " msgId:" + num2 + " " + stringBuilder); } NetworkMessageDelegate networkMessageDelegate = null; if (m_MessageHandlersDict.ContainsKey(num2)) { networkMessageDelegate = m_MessageHandlersDict[num2]; } if (networkMessageDelegate == null) { break; } m_NetMsg.msgType = num2; m_NetMsg.reader = reader2; m_NetMsg.conn = this; m_NetMsg.channelId = channelId; networkMessageDelegate(m_NetMsg); lastMessageTime = Time.time; } if (LogFilter.logError) { Debug.LogError("Unknown message ID " + num2 + " connId:" + connectionId); } }
public bool InvokeHandler(NetworkMessage netMsg) { bool result; if (this.m_MessageHandlersDict.ContainsKey(netMsg.msgType)) { NetworkMessageDelegate networkMessageDelegate = this.m_MessageHandlersDict[netMsg.msgType]; networkMessageDelegate(netMsg); result = true; } else { result = false; } return(result); }
internal void RegisterHandlerSafe(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (LogFilter.logError) { Debug.LogError("RegisterHandlerSafe id:" + msgType + " handler is null"); } return; } if (LogFilter.logDebug) { Debug.Log("RegisterHandlerSafe id:" + msgType + " handler:" + handler.Method.Name); } if (!m_MsgHandlers.ContainsKey(msgType)) { m_MsgHandlers.Add(msgType, handler); } }
/// <summary> /// <para>This function invokes the registered handler function for a message.</para> /// </summary> /// <param name="msgType">The message type of the handler to use.</param> /// <param name="reader">The stream to read the contents of the message from.</param> /// <param name="channelId">The channel that the message arrived on.</param> /// <param name="netMsg">The message object to process.</param> /// <returns> /// <para>True if a handler function was found and invoked.</para> /// </returns> public bool InvokeHandler(short msgType, NetworkReader reader, int channelId) { if (this.m_MessageHandlersDict.ContainsKey(msgType)) { this.m_MessageInfo.msgType = msgType; this.m_MessageInfo.conn = this; this.m_MessageInfo.reader = reader; this.m_MessageInfo.channelId = channelId; NetworkMessageDelegate delegate2 = this.m_MessageHandlersDict[msgType]; if (delegate2 == null) { if (LogFilter.logError) { Debug.LogError("NetworkConnection InvokeHandler no handler for " + msgType); } return(false); } delegate2(this.m_MessageInfo); return(true); } return(false); }
internal void RegisterHandlerSafe(short msgType, NetworkMessageDelegate handler) { if (handler == null) { if (!LogFilter.logError) { return; } Debug.LogError((object)("RegisterHandlerSafe id:" + (object)msgType + " handler is null")); } else { if (LogFilter.logDebug) { Debug.Log((object)("RegisterHandlerSafe id:" + (object)msgType + " handler:" + handler.Method.Name)); } if (this.m_MsgHandlers.ContainsKey(msgType)) { return; } this.m_MsgHandlers.Add(msgType, handler); } }
public virtual void RegisterMessaging(short msgType, [NotNull] UnityEngine.Networking.NetworkMessageDelegate callback) { throw new NotImplementedException(); }
public void RegisterHandler(short msgType, NetworkMessageDelegate handler) { this.m_MessageHandlers.RegisterHandler(msgType, handler); }
/// <summary> /// This makes the connection process the data contained in the stream, and call handler functions. /// <para>The data in the stream is assumed to have come from the network, and contains network messages.</para> /// <para>This function is used by network connections when they receive data.</para> /// </summary> /// <param name="reader">Stream that contains data.</param> /// <param name="receivedSize">Size of the data.</param> /// <param name="channelId">Channel the data was received on.</param> protected void HandleReader( NetworkReader reader, int receivedSize, int channelId) { // read until size is reached. // NOTE: stream.Capacity is 1300, NOT the size of the available data while (reader.Position < receivedSize) { // the reader passed to user code has a copy of bytes from the real stream. user code never touches the real stream. // this ensures it can never get out of sync if user code reads less or more than the real amount. ushort sz = reader.ReadUInt16(); short msgType = reader.ReadInt16(); // create a reader just for this message //TODO: Allocation!! byte[] msgBuffer = reader.ReadBytes(sz); NetworkReader msgReader = new NetworkReader(msgBuffer); if (logNetworkMessages) { StringBuilder msg = new StringBuilder(); for (int i = 0; i < sz; i++) { msg.AppendFormat("{0:X2}", msgBuffer[i]); if (i > k_MaxMessageLogSize) { break; } } Debug.Log("ConnectionRecv con:" + connectionId + " bytes:" + sz + " msgId:" + msgType + " " + msg); } NetworkMessageDelegate msgDelegate = null; if (m_MessageHandlersDict.ContainsKey(msgType)) { msgDelegate = m_MessageHandlersDict[msgType]; } if (msgDelegate != null) { m_NetMsg.msgType = msgType; m_NetMsg.reader = msgReader; m_NetMsg.conn = this; m_NetMsg.channelId = channelId; msgDelegate(m_NetMsg); lastMessageTime = Time.time; #if UNITY_EDITOR Profiler.IncrementStatIncoming(MsgType.HLAPIMsg); if (msgType > MsgType.Highest) { Profiler.IncrementStatIncoming(MsgType.UserMessage, msgType + ":" + msgType.GetType().Name); } #endif #if UNITY_EDITOR if (m_PacketStats.ContainsKey(msgType)) { PacketStat stat = m_PacketStats[msgType]; stat.count += 1; stat.bytes += sz; } else { PacketStat stat = new PacketStat(); stat.msgType = msgType; stat.count += 1; stat.bytes += sz; m_PacketStats[msgType] = stat; } #endif } else { //NOTE: this throws away the rest of the buffer. Need moar error codes if (LogFilter.logError) { Debug.LogError("Unknown message ID " + msgType + " connId:" + connectionId); } break; } } }
/// <summary> /// This makes the connection process the data contained in the stream, and call handler functions. /// <para>The data in the stream is assumed to have come from the network, and contains network messages.</para> /// <para>This function is used by network connections when they receive data.</para> /// </summary> /// <param name="reader">Stream that contains data.</param> /// <param name="receivedSize">Size of the data.</param> /// <param name="channelId">Channel the data was received on.</param> protected void HandleReader( NetworkReader reader, int receivedSize, int channelId) { // read until size is reached. // NOTE: stream.Capacity is 1300, NOT the size of the available data while (reader.Position < receivedSize) { // the reader passed to user code has a copy of bytes from the real stream. user code never touches the real stream. // this ensures it can never get out of sync if user code reads less or more than the real amount. ushort sz = reader.ReadUInt16(); short msgType = reader.ReadInt16(); // Bail out here if we're about to read beyond the recieved size of the buffer // This could be a sign of an attack which could cause us to behave unexpectedly by reading old data if (reader.Position + sz > receivedSize) { if (LogFilter.logError) { Debug.LogError("Declared packet size larger than recieved size, possible corruption or attack"); } break; } // create a reader just for this message //TODO: Allocation!! byte[] msgBuffer = reader.ReadBytes(sz); NetworkReader msgReader = new NetworkReader(msgBuffer); if (logNetworkMessages) { StringBuilder msg = new StringBuilder(); for (int i = 0; i < sz; i++) { msg.AppendFormat("{0:X2}", msgBuffer[i]); if (i > k_MaxMessageLogSize) { break; } } Debug.Log("ConnectionRecv con:" + connectionId + " bytes:" + sz + " msgId:" + msgType + " " + msg); } NetworkMessageDelegate msgDelegate = null; if (m_MessageHandlersDict.ContainsKey(msgType)) { msgDelegate = m_MessageHandlersDict[msgType]; } if (msgDelegate != null) { m_NetMsg.msgType = msgType; m_NetMsg.reader = msgReader; m_NetMsg.conn = this; m_NetMsg.channelId = channelId; msgDelegate(m_NetMsg); lastMessageTime = Time.time; #if UNITY_EDITOR if (m_PacketStats.ContainsKey(msgType)) { PacketStat stat = m_PacketStats[msgType]; stat.count += 1; stat.bytes += sz; } else { PacketStat stat = new PacketStat(); stat.msgType = msgType; stat.count += 1; stat.bytes += sz; m_PacketStats[msgType] = stat; } #endif } else { //NOTE: this throws away the rest of the buffer. Need moar error codes if (LogFilter.logError) { Debug.LogError("Unknown message ID " + msgType + " connId:" + connectionId); } break; } } }
internal void RegisterHandlerSafe(short msgType, NetworkMessageDelegate handler) { this.m_MessageHandlers.RegisterHandlerSafe(msgType, handler); }
protected void HandleReader( NetworkReader reader, int receivedSize, int channelId) { // read until size is reached. // NOTE: stream.Capacity is 1300, NOT the size of the available data while (reader.Position < receivedSize) { // the reader passed to user code has a copy of bytes from the real stream. user code never touches the real stream. // this ensures it can never get out of sync if user code reads less or more than the real amount. ushort sz = reader.ReadUInt16(); short msgType = reader.ReadInt16(); // create a reader just for this message byte[] msgBuffer = reader.ReadBytes(sz); NetworkReader msgReader = new NetworkReader(msgBuffer); if (logNetworkMessages) { StringBuilder msg = new StringBuilder(); for (int i = 0; i < sz; i++) { msg.AppendFormat("{0:X2}", msgBuffer[i]); if (i > k_MaxMessageLogSize) { break; } } Debug.Log("ConnectionRecv con:" + connectionId + " bytes:" + sz + " msgId:" + msgType + " " + msg); } NetworkMessageDelegate msgDelegate = null; if (m_MessageHandlersDict.ContainsKey(msgType)) { msgDelegate = m_MessageHandlersDict[msgType]; } if (msgDelegate != null) { // create message here instead of caching it. so we can add it to queue more easily. NetworkMessage msg = new NetworkMessage(); msg.msgType = msgType; msg.reader = msgReader; msg.conn = this; msg.channelId = channelId; // add to queue while paused, otherwise process directly if (pauseQueue != null) { pauseQueue.Enqueue(msg); if (LogFilter.logWarn) { Debug.LogWarning("HandleReader: added message to pause queue: " + msgType + " str=" + MsgType.MsgTypeToString(msgType) + " queue size=" + pauseQueue.Count); } } else { msgDelegate(msg); } lastMessageTime = Time.time; #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, MsgType.HLAPIMsg, "msg", 1); if (msgType > MsgType.Highest) { UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, MsgType.UserMessage, msgType.ToString() + ":" + msgType.GetType().Name, 1); } #endif #if UNITY_EDITOR if (m_PacketStats.ContainsKey(msgType)) { PacketStat stat = m_PacketStats[msgType]; stat.count += 1; stat.bytes += sz; } else { PacketStat stat = new PacketStat(); stat.msgType = msgType; stat.count += 1; stat.bytes += sz; m_PacketStats[msgType] = stat; } #endif } else { //NOTE: this throws away the rest of the buffer. Need moar error codes if (LogFilter.logError) { Debug.LogError("Unknown message ID " + msgType + " connId:" + connectionId); } break; } } }
/// <summary> /// <para>This makes the connection process the data contained in the stream, and call handler functions.</para> /// </summary> /// <param name="reader">Stream that contains data.</param> /// <param name="receivedSize">Size of the data.</param> /// <param name="channelId">Channel the data was received on.</param> protected void HandleReader(NetworkReader reader, int receivedSize, int channelId) { while (reader.Position < receivedSize) { ushort count = reader.ReadUInt16(); short key = reader.ReadInt16(); byte[] buffer = reader.ReadBytes(count); NetworkReader reader2 = new NetworkReader(buffer); if (this.logNetworkMessages) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < count; i++) { builder.AppendFormat("{0:X2}", buffer[i]); if (i > 150) { break; } } Debug.Log(string.Concat(new object[] { "ConnectionRecv con:", this.connectionId, " bytes:", count, " msgId:", key, " ", builder })); } NetworkMessageDelegate delegate2 = null; if (this.m_MessageHandlersDict.ContainsKey(key)) { delegate2 = this.m_MessageHandlersDict[key]; } if (delegate2 != null) { this.m_NetMsg.msgType = key; this.m_NetMsg.reader = reader2; this.m_NetMsg.conn = this; this.m_NetMsg.channelId = channelId; delegate2(this.m_NetMsg); this.lastMessageTime = Time.time; NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 0x1c, "msg", 1); if (key > 0x2f) { NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 0, key.ToString() + ":" + key.GetType().Name, 1); } if (this.m_PacketStats.ContainsKey(key)) { PacketStat stat = this.m_PacketStats[key]; stat.count++; stat.bytes += count; } else { PacketStat stat2 = new PacketStat { msgType = key }; stat2.count++; stat2.bytes += count; this.m_PacketStats[key] = stat2; } } else { if (LogFilter.logError) { Debug.LogError(string.Concat(new object[] { "Unknown message ID ", key, " connId:", this.connectionId })); } break; } } }
/// <summary> /// <para>This makes the connection process the data contained in the stream, and call handler functions.</para> /// </summary> /// <param name="reader">Stream that contains data.</param> /// <param name="receivedSize">Size of the data.</param> /// <param name="channelId">Channel the data was received on.</param> protected void HandleReader(NetworkReader reader, int receivedSize, int channelId) { while ((long)reader.Position < (long)receivedSize) { ushort num = reader.ReadUInt16(); short key = reader.ReadInt16(); byte[] buffer = reader.ReadBytes((int)num); NetworkReader networkReader = new NetworkReader(buffer); if (this.logNetworkMessages) { StringBuilder stringBuilder = new StringBuilder(); for (int index = 0; index < (int)num; ++index) { stringBuilder.AppendFormat("{0:X2}", (object)buffer[index]); if (index > 150) { break; } } Debug.Log((object)("ConnectionRecv con:" + (object)this.connectionId + " bytes:" + (object)num + " msgId:" + (object)key + " " + (object)stringBuilder)); } NetworkMessageDelegate networkMessageDelegate = (NetworkMessageDelegate)null; if (this.m_MessageHandlersDict.ContainsKey(key)) { networkMessageDelegate = this.m_MessageHandlersDict[key]; } if (networkMessageDelegate != null) { this.m_NetMsg.msgType = key; this.m_NetMsg.reader = networkReader; this.m_NetMsg.conn = this; this.m_NetMsg.channelId = channelId; networkMessageDelegate(this.m_NetMsg); this.lastMessageTime = Time.time; NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)28, "msg", 1); if ((int)key > 47) { NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)0, key.ToString() + ":" + key.GetType().Name, 1); } if (this.m_PacketStats.ContainsKey(key)) { NetworkConnection.PacketStat packetStat = this.m_PacketStats[key]; ++packetStat.count; packetStat.bytes += (int)num; } else { NetworkConnection.PacketStat packetStat = new NetworkConnection.PacketStat(); packetStat.msgType = key; ++packetStat.count; packetStat.bytes += (int)num; this.m_PacketStats[key] = packetStat; } } else { if (!LogFilter.logError) { break; } Debug.LogError((object)("Unknown message ID " + (object)key + " connId:" + (object)this.connectionId)); break; } } }
public void RegisterHandlerSafe(short msgType, NetworkMessageDelegate handler) { m_MessageHandlers.RegisterHandlerSafe(msgType, handler); }
internal static void RegisterSystemHandlers(NetworkClient client, bool localClient) { if (localClient) { short msgType = 1; if (ClientScene.< > f__mg$cache0 == null) { ClientScene.< > f__mg$cache0 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectDestroy); } client.RegisterHandlerSafe(msgType, ClientScene.< > f__mg$cache0); short msgType2 = 13; if (ClientScene.< > f__mg$cache1 == null) { ClientScene.< > f__mg$cache1 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectHide); } client.RegisterHandlerSafe(msgType2, ClientScene.< > f__mg$cache1); short msgType3 = 3; if (ClientScene.< > f__mg$cache2 == null) { ClientScene.< > f__mg$cache2 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawn); } client.RegisterHandlerSafe(msgType3, ClientScene.< > f__mg$cache2); short msgType4 = 10; if (ClientScene.< > f__mg$cache3 == null) { ClientScene.< > f__mg$cache3 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawnScene); } client.RegisterHandlerSafe(msgType4, ClientScene.< > f__mg$cache3); short msgType5 = 15; if (ClientScene.< > f__mg$cache4 == null) { ClientScene.< > f__mg$cache4 = new NetworkMessageDelegate(ClientScene.OnClientAuthority); } client.RegisterHandlerSafe(msgType5, ClientScene.< > f__mg$cache4); } else { short msgType6 = 3; if (ClientScene.< > f__mg$cache5 == null) { ClientScene.< > f__mg$cache5 = new NetworkMessageDelegate(ClientScene.OnObjectSpawn); } client.RegisterHandlerSafe(msgType6, ClientScene.< > f__mg$cache5); short msgType7 = 10; if (ClientScene.< > f__mg$cache6 == null) { ClientScene.< > f__mg$cache6 = new NetworkMessageDelegate(ClientScene.OnObjectSpawnScene); } client.RegisterHandlerSafe(msgType7, ClientScene.< > f__mg$cache6); short msgType8 = 12; if (ClientScene.< > f__mg$cache7 == null) { ClientScene.< > f__mg$cache7 = new NetworkMessageDelegate(ClientScene.OnObjectSpawnFinished); } client.RegisterHandlerSafe(msgType8, ClientScene.< > f__mg$cache7); short msgType9 = 1; if (ClientScene.< > f__mg$cache8 == null) { ClientScene.< > f__mg$cache8 = new NetworkMessageDelegate(ClientScene.OnObjectDestroy); } client.RegisterHandlerSafe(msgType9, ClientScene.< > f__mg$cache8); short msgType10 = 13; if (ClientScene.< > f__mg$cache9 == null) { ClientScene.< > f__mg$cache9 = new NetworkMessageDelegate(ClientScene.OnObjectDestroy); } client.RegisterHandlerSafe(msgType10, ClientScene.< > f__mg$cache9); short msgType11 = 8; if (ClientScene.< > f__mg$cacheA == null) { ClientScene.< > f__mg$cacheA = new NetworkMessageDelegate(ClientScene.OnUpdateVarsMessage); } client.RegisterHandlerSafe(msgType11, ClientScene.< > f__mg$cacheA); short msgType12 = 4; if (ClientScene.< > f__mg$cacheB == null) { ClientScene.< > f__mg$cacheB = new NetworkMessageDelegate(ClientScene.OnOwnerMessage); } client.RegisterHandlerSafe(msgType12, ClientScene.< > f__mg$cacheB); short msgType13 = 9; if (ClientScene.< > f__mg$cacheC == null) { ClientScene.< > f__mg$cacheC = new NetworkMessageDelegate(ClientScene.OnSyncListMessage); } client.RegisterHandlerSafe(msgType13, ClientScene.< > f__mg$cacheC); short msgType14 = 40; if (ClientScene.< > f__mg$cacheD == null) { ClientScene.< > f__mg$cacheD = new NetworkMessageDelegate(NetworkAnimator.OnAnimationClientMessage); } client.RegisterHandlerSafe(msgType14, ClientScene.< > f__mg$cacheD); short msgType15 = 41; if (ClientScene.< > f__mg$cacheE == null) { ClientScene.< > f__mg$cacheE = new NetworkMessageDelegate(NetworkAnimator.OnAnimationParametersClientMessage); } client.RegisterHandlerSafe(msgType15, ClientScene.< > f__mg$cacheE); short msgType16 = 15; if (ClientScene.< > f__mg$cacheF == null) { ClientScene.< > f__mg$cacheF = new NetworkMessageDelegate(ClientScene.OnClientAuthority); } client.RegisterHandlerSafe(msgType16, ClientScene.< > f__mg$cacheF); } short msgType17 = 2; if (ClientScene.< > f__mg$cache10 == null) { ClientScene.< > f__mg$cache10 = new NetworkMessageDelegate(ClientScene.OnRPCMessage); } client.RegisterHandlerSafe(msgType17, ClientScene.< > f__mg$cache10); short msgType18 = 7; if (ClientScene.< > f__mg$cache11 == null) { ClientScene.< > f__mg$cache11 = new NetworkMessageDelegate(ClientScene.OnSyncEventMessage); } client.RegisterHandlerSafe(msgType18, ClientScene.< > f__mg$cache11); short msgType19 = 42; if (ClientScene.< > f__mg$cache12 == null) { ClientScene.< > f__mg$cache12 = new NetworkMessageDelegate(NetworkAnimator.OnAnimationTriggerClientMessage); } client.RegisterHandlerSafe(msgType19, ClientScene.< > f__mg$cache12); }