Exemple #1
0
        public void SendRPC(RMPNetworkView sender, QosType channel, string methodName, params object[] parameters)
        {
            if (string.IsNullOrEmpty(sender.Guid))
            {
                Debug.LogWarning("RPC Aborted : The Guid is empty.");
                return;
            }

            if (parameters == null)
            {
                Debug.LogWarning("RPC Aborted : Parameters array can not be null.");
                return;
            }

            var msg = new Packet();

            msg.Write((byte)RMPEncoding.ProtocolId.RPC);
            msg.Write(sender.Guid);
            msg.Write(methodName);
            msg.Write(parameters.Length);

            foreach (object param in parameters)
            {
                RMPEncoding.WriteParameter(msg, param);
            }

            NetworkService.Send(HostId, ConnectionId, msg);
        }
Exemple #2
0
        private void ReceiveRPC(Packet msg)
        {
            var guid        = msg.ReadString();
            var methodName  = msg.ReadString();
            var numOfParams = msg.ReadInt32();
            var parameters  = new object[numOfParams];

            for (int i = 0; i < numOfParams; ++i)
            {
                parameters[i] = RMPEncoding.ReadParameter(msg);
            }

            var target = RMPNetworkView.Get(guid);

            target?.SendReflectionMessage(this, methodName, parameters);
        }