Example #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.Push((byte)RMPEncoding.ProtocolId.RPC);
            msg.Push(sender.Guid);
            msg.Push(methodName);
            msg.Push(parameters.Length);

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

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

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

            try
            {
                var target = RMPNetworkView.Get(guid);
                target.SendReflectionMessage(this, methodName, parameters);
            }
            catch (Exception error)
            {
                Debug.LogError(error);
            }
        }