Beispiel #1
0
        private void SendCmdMessage(MqttHelper mqttHelper, string rid, NetCmdIdClient cid, byte[] cmd)
        {
            //SendCommend sendCommend = new SendCommend();
            //sendCommend.id = (int)NetCmdId.SendCmmond;
            //sendCommend.data = new SendCommend.ResultBean();
            //sendCommend.data.cmd = cmd;
            //string json = JsonConvert.SerializeObject(sendCommend);
            byte[] bId = BitConverter.GetBytes((int)cid);

            byte[] sendBuf = new byte[4 + cmd.Length];
            Array.Copy(bId, 0, sendBuf, 0, bId.Length);
            Array.Copy(cmd, 0, sendBuf, 4, cmd.Length);
            bId = null;
            cmd = null;

            mqttHelper.PublishMsg(MessageType.Group, rid, sendBuf, new MqttSendMsgDelegate((bool res) =>
            {
            }));
        }
Beispiel #2
0
        private void NetWork_onReceiveCmd(string rid, NetCmdIdClient cid, object cmd)
        {
            if (rid != null && rid.Equals(this.roomId))
            {
                switch (cid)
                {
                case NetCmdIdClient.None:
                    break;

                case NetCmdIdClient.AnchorUploaded:
                {
                    if (clientType != ClientType.SpectatorViewPc &&
                        clientType != ClientType.IOS)
                    {
                        AnchorUploaded clientCmd = (AnchorUploaded)cmd;


                        this.anchorName = clientCmd.anchor;
                        OperationBean oper = new OperationBean();
                        oper.op    = OperationBean.OpId.DownAnchor;
                        oper.param = anchorName;

                        operationQueue.Enqueue(oper);
                    }
                }
                break;

                case NetCmdIdClient.TakeControlPower:
                {
                    //TakeControlPower clientCmd = (TakeControlPower)cmd;
                }
                break;

                case NetCmdIdClient.SyncPos:
                {
                    SyncPos clientCmd = (SyncPos)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            SpectatorViewPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvPosition(new Vector3(clientCmd.px, clientCmd.py, clientCmd.pz), clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncRotate:
                {
                    SyncRotate clientCmd = (SyncRotate)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            SpectatorViewPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvRotation(new Vector3(clientCmd.rx, clientCmd.ry, clientCmd.rz), clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncAnim:
                {
                    SyncAnim clientCmd = (SyncAnim)cmd;
                    if (clientCmd.type == SyncType.SpectatorView)
                    {
                    }
                }
                break;

                case NetCmdIdClient.OtherCmd:
                {
                    OtherCmd      clientCmd = (OtherCmd)cmd;
                    OperationBean op        = new OperationBean();
                    op.op    = OperationBean.OpId.OtherCmd;
                    op.param = clientCmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.FloorLocated:
                {
                    FloorLocated clientCmd = (FloorLocated)cmd;
                    _lerpStageWithFloor = clientCmd.y;

                    Vector3 v = new Vector3(clientCmd.x, clientCmd.y, clientCmd.z);

                    //TODO---->>>> GeMesCar测试数据
                    //ipad
                    if (clientType == ClientType.IOS)
                    {
                        OperationBean op = new OperationBean();
                        op.op    = OperationBean.OpId.ios_AdjustFloorLocate;
                        op.param = v;
                        operationQueue.Enqueue(op);
                    }
                    else
                    {
                        OperationBean op = new OperationBean();
                        op.op    = OperationBean.OpId.hololens_AdjustFloorLocate;
                        op.param = v;
                        operationQueue.Enqueue(op);
                    }
                    Debug.Log("收到creater定位地面的消息-->>>>>    " + v.ToString());
                }
                break;

                case NetCmdIdClient.MarkerGenerated:
                {
                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.MarkerGenerated;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.MarkerDetected:
                {
                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.MarkerDetected;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.SyncWorldRoot:
                {
                    Debug.Log("SpectatorViewManager#NetWork_onReceiveCmd#SyncWorldRoot");

                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.SyncWorldRoot;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;
                }
            }
        }
Beispiel #3
0
        private void onReceiveCmdFunc(string rid, byte[] cmd)
        {
            if (cmd.Length < 4)
            {
                return;
            }
            byte[] idBuf = new byte[4];
            Array.Copy(cmd, 0, idBuf, 0, 4);

            byte[] body = null;
            if (cmd.Length > 4)
            {
                body = new byte[cmd.Length - 4];
                Array.Copy(cmd, 4, body, 0, body.Length);
            }

            NetCmdIdClient cid = (NetCmdIdClient)BitConverter.ToInt32(cmd, 0);

            object cmdObj = null;

            switch (cid)
            {
            case NetCmdIdClient.None:
                break;

            case NetCmdIdClient.AnchorUploaded:
                cmdObj = DecodeStruct <AnchorUploaded>(body);
                break;

            case NetCmdIdClient.TakeControlPower:
                cmdObj = DecodeStruct <TakeControlPower>(body);
                break;

            case NetCmdIdClient.SyncPos:
                cmdObj = DecodeStruct <SyncPos>(body);
                break;

            case NetCmdIdClient.SyncRotate:
                cmdObj = DecodeStruct <SyncRotate>(body);
                break;

            case NetCmdIdClient.SyncAnim:
                cmdObj = DecodeStruct <SyncAnim>(body);
                break;

            case NetCmdIdClient.MenuShowHide:
                cmdObj = DecodeStruct <MenuShowHide>(body);
                break;

            case NetCmdIdClient.MenuSelectItem:
                cmdObj = DecodeStruct <MenuSelectItem>(body);
                break;

            case NetCmdIdClient.OtherCmd:
                cmdObj = DecodeStruct <OtherCmd>(body);

                break;

            case NetCmdIdClient.FloorLocated:
                cmdObj = DecodeStruct <FloorLocated>(body);
                break;

            case NetCmdIdClient.MarkerGenerated:
                cmdObj = DecodeStruct <MarkerGenerated>(body);
                break;

            case NetCmdIdClient.MarkerDetected:
                cmdObj = DecodeStruct <MarkerDetected>(body);
                break;

            case NetCmdIdClient.SyncWorldRoot:
                cmdObj = DecodeStruct <SyncWorldRoot>(body);
                break;
            }
            if (cmdObj != null)
            {
                onReceiveCmd?.Invoke(rid, cid, cmdObj);
            }
        }
Beispiel #4
0
        private void NetWork_onReceiveCmd(string rid, NetCmdIdClient cid, object cmd)
        {
            if (rid != null && rid.Equals(this.roomId))
            {
                switch (cid)
                {
                case NetCmdIdClient.None:
                    break;

                case NetCmdIdClient.AnchorUploaded:
                {
                    //AnchorUploaded clientCmd = (AnchorUploaded)cmd;
                }
                break;

                case NetCmdIdClient.TakeControlPower:
                {
                    //TakeControlPower clientCmd = (TakeControlPower)cmd;
                    isControler = false;
                }
                break;

                case NetCmdIdClient.SyncPos:
                {
                    SyncPos clientCmd = (SyncPos)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            VirtualManPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvPosition(new Vector3(clientCmd.px, clientCmd.py, clientCmd.pz),
                                                      clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncRotate:
                {
                    SyncRotate clientCmd = (SyncRotate)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            VirtualManPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvRotation(new Vector3(clientCmd.rx, clientCmd.ry, clientCmd.rz),
                                                      clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncAnim:
                {
                    SyncAnim clientCmd = (SyncAnim)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            VirtualManPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.onRecvAnimation(clientCmd.amimid, clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.OtherCmd:
                {
                    OtherCmd      clientCmd = (OtherCmd)cmd;
                    OperationBean op        = new OperationBean();
                    op.op    = OperationBean.OpId.OtherCmd;
                    op.param = clientCmd;
                    operationQueue.Enqueue(op);
                }
                break;
                }
            }
        }