Пример #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);
        }
Пример #2
0
        public void SendRemove(RMPNetworkView view)
        {
            var msg = new Packet();

            msg.Push((byte)RMPEncoding.ProtocolId.Remove);
            msg.Push(view.Guid);
            NetworkService.Send(HostId, ConnectionId, msg);
        }
Пример #3
0
        public void SendReplicate(RMPNetworkView view)
        {
            var msg = new Packet();

            msg.Push((byte)RMPEncoding.ProtocolId.Replicate);
            msg.Push(view.ReplicationTableIndex);
            msg.Push(view.Guid);

            // 서버는 클라에 함께 보낼 데이터를 넣는다.
            view.SendReflectionMessage(null, "OnReplicate", msg);

            NetworkService.Send(HostId, ConnectionId, msg);
        }
Пример #4
0
        private void ReceiveRemove(Packet msg)
        {
            var guid = msg.PopString();

            try
            {
                var target = RMPNetworkView.Get(guid);
                UnityEngine.Object.Destroy(target.gameObject);
            }
            catch (Exception error)
            {
                Debug.LogError(error);
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
        public static void Replicate(RMPNetworkView view, RMPPeer to = null)
        {
            if (!NetworkService.IsServer)
            {
                Debug.LogError("Only server can replicate RMP object. Replication aborted.");
                return;
            }

            if (to == null)
            {
                var cls = RMPPeer.ClientPeers;
                if (cls != null)
                {
                    foreach (var peer in cls.Values)
                    {
                        peer.SendReplicate(view);
                    }
                }
            }
            else
            {
                to.SendReplicate(view);
            }
        }