public void InvokeRpc(string name, INetworkPeer receiver, PacketFlags?flags, params object[] args)
        {
            GuardComponentId();

            var normalizedName = name.ToLowerInvariant();

            var serializedArgs = SerializeArgs(args);

            var methodIndex = s_RpcMethodsMappings[GetType()][normalizedName];
            var packet      = new RpcPacket
            {
                Arguments   = serializedArgs,
                ComponentId = ComponentId.Value,
                MethodIndex = methodIndex
            };

            var serializedPacket = m_Serializer.Serialize(packet);

            var packetDescription = m_ConnectionHandler.GetPacketDescription(methodIndex);

            if (flags != null)
            {
                packetDescription             = packetDescription.Clone();
                packetDescription.PacketFlags = flags.Value;
            }

            m_ConnectionHandler.Send(new OutgoingPacket
            {
                Data = serializedPacket,
                PacketDescription = packetDescription,
                PacketId          = (byte)PacketType.Rpc,
                Peers             = new[] { receiver }
            });
        }
        private void HandleIncomingPacket(INetworkPeer peer, byte packetId, byte[] packetBody, byte channelId)
        {
            var packetDescription = m_ConnectionHandler.GetPacketDescription(packetId);

#if LOG_NETWORK
            m_Logger.LogDebug($"[Network] < {packetDescription.Name}");
#endif
            if (!m_PacketHandlers.ContainsKey(packetId))
            {
#if LOG_NETWORK
                m_Logger.LogWarning($"Failed to handle packet \"{packetId}\" from {peer}: No matching handler was found.");
#endif
                return;
            }

            var handlers = m_PacketHandlers[packetId];
            foreach (var handler in handlers)
            {
                handler.HandlePacket(new IncomingPacket
                {
                    ChannelId = channelId,
                    PacketId  = (byte)packetId,
                    Data      = packetBody,
                    Peer      = peer
                });
            }
        }