Exemplo n.º 1
0
        public void Process(string message)
        {
            var letter = MessageJsonSerializer.DeserializeMessage <Letter>(message);

            if (letter != null)
            {
                LetterReceived?.Invoke(letter);
                return;
            }

            var userNetworkEvent = MessageJsonSerializer.DeserializeMessage <UserNetworkEvent>(message);

            if (userNetworkEvent != null)
            {
                NetworkEventReceived?.Invoke(userNetworkEvent);
                return;
            }


            var charUsers = MessageJsonSerializer.DeserializeMessage <ChatUsers>(message);

            if (charUsers != null)
            {
                ChatUsersReceived?.Invoke(charUsers);
                return;
            }

            var nameSet = MessageJsonSerializer.DeserializeMessage <NameSet>(message);

            if (nameSet != null)
            {
                NameSetReceived?.Invoke(nameSet);
                return;
            }
        }
Exemplo n.º 2
0
    private void OnEvent(byte eventcode, object content, int senderid)
    {
        EventCode @event = (EventCode)eventcode;

        if (@event == EventCode.InstantiateVRAvatar)
        {
            GameObject go = null;

            if (PhotonNetwork.player.ID != senderid)
            {
                var data = (Dictionary <string, object>)content;

                go = Instantiate(RemotePlayer) as GameObject;
                go.transform.position = (Vector3)data["Position"];

                var remotePlayerManager = go.GetComponent <RemotePlayerManager>();
                remotePlayerManager.NetworkManager = this;
                remotePlayerManager.InitializeNetworkManager();

                PhotonView pView = go.GetComponent <PhotonView>();

                if (pView != null)
                {
                    pView.viewID = (int)data["ViewID"];
                }

                if (_voiceRecorder != null)
                {
                    _voiceRecorder.Transmit = false;
                    _voiceRecorder.Transmit = true;
                }
            }
        }

        if (PhotonNetwork.player.ID != senderid)
        {
            NetworkEventReceived?.Invoke(this, new NetworkEventReceivedEventArgs
            {
                Content   = content,
                EventCode = @event
            });
        }
    }