Пример #1
0
        public void onRecive_CalleeCreateIceCandite(websocketMsgTemp <IceCandidate> e)
        {
            string remoteMachineId = e.sendMachineId;
            var    icecandidate    = e.content;

            this.ControllerLogic?.AddRemoteIceCandite(remoteMachineId, icecandidate);
        }
Пример #2
0
 private void WebSocketClient_OnMessage(object sender, websocketMsgTemp <object> e)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         this.wsclient.DealMessage(this, e);
     }));
 }
Пример #3
0
        public void onRecive_CreateAnswer(websocketMsgTemp <SdpInfo> e)
        {
            string remoteMachineId = e.sendMachineId;
            //, object remoteAnswer
            var sdpinfo = e.content;

            this.ControllerLogic.SetRemoteAnswer(remoteMachineId, sdpinfo);
        }
Пример #4
0
        public void onRecive_CreateOffer(websocketMsgTemp <SdpInfo> e)
        {
            string remoteMachineId = e.sendMachineId;
            //var sdpinfo = JsonConvert.DeserializeObject<SdpInfo>(JsonConvert.SerializeObject(remoteOffer));
            var sdpinfo = e.content;

            this.BeControllerLogic.ReciveRemoteConnection(remoteMachineId, sdpinfo);
        }
        ///***************************************************
        ///
        public static void SendMessage(string remoteMachineId, object content, msgType msgtype)
        {
            websocketMsgTemp <object> data = new websocketMsgTemp <object>();

            data.senderId   = MachineLogic.localMachine().machineId;
            data.receiverId = remoteMachineId;
            data.msgType    = msgtype;
            data.content    = content;
            wsclient.Send(JsonConvert.SerializeObject(data));
        }
Пример #6
0
        public void onMyMachineNameChange(websocketMsgTemp <object> e)
        {
            string sendMachineId = e.sendMachineId;
            object conten        = e.content;

            var findmachine = this.myMachines.FirstOrDefault(o => o.machineId == sendMachineId);

            if (findmachine != null)
            {
                findmachine.machineName = conten?.ToString();
                this.myMachines.Remove(findmachine);
                this.myMachines.Insert(0, findmachine);
                this.OnPropertyChanged(nameof(myMachines));
            }
        }
Пример #7
0
        public void onRecive_RequestConnect(websocketMsgTemp <object> e)
        {
            string remoteMachineId = e.sendMachineId;
            string machinePwd      = e.content.ToString();


            if (machinePwd == this.CurrentMachine.machinepwd && this.BeControllerLogic.CanConnect == true)
            {
                WebSocketClient.SendMessage(remoteMachineId, true, msgType.client_onAnswerRequestConnect);
            }
            else
            {
                WebSocketClient.SendMessage(remoteMachineId, false, msgType.client_onAnswerRequestConnect);
            }
        }
Пример #8
0
        public void onMachineOnLine(websocketMsgTemp <LYLUserMachineInfo> data)
        {
            LYLUserMachineInfo machine = data.content;
            var findmachine            = myMachines.FirstOrDefault(o => o.machineId == machine.machineId);

            if (findmachine == null)
            {
                this.myMachines.Add(machine);
            }
            else
            {
                findmachine.machinePwd  = machine.machinePwd;
                findmachine.machineName = machine.machineName;
            }
            this.OnPropertyChanged(nameof(this.myMachines));
        }
Пример #9
0
        public void onRecive_AnswerRequestConnect(websocketMsgTemp <object> e)
        {
            string remoteMachineId = e.sendMachineId;
            var    isAgree         = bool.Parse(e.content.ToString());

            if (isAgree == false)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    ErrorDialogCon con = new ErrorDialogCon();
                    con.ErrorMsg       = "对方不同意链接";
                    DialogHost.Show(con);
                });
                return;
            }
            this.ControllerLogic.ConnectMachine(remoteMachineId);
        }
Пример #10
0
        ///**************************************************
        ///
        public void DealMessage(object messageHandleClass, websocketMsgTemp <object> e)
        {
            foreach (var method in messageHandleClass.GetType().GetMethods())
            {
                var attrs = method.GetCustomAttributes(typeof(MessageTypeAttribute), true) as MessageTypeAttribute[];
                if (attrs.Length < 1)
                {
                    continue;
                }

                var find = attrs.FirstOrDefault(o => o.msgType == e.msgType);
                if (find == null)
                {
                    continue;
                }

                var param = method.GetParameters()[0];
                var data  = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(e), param.ParameterType);
                method.Invoke(messageHandleClass, new object[] { data });
                break;
            }
        }
Пример #11
0
        public void onClientNotOnLine(websocketMsgTemp <LYLUserMachineInfo> data)
        {
            ErrorDialogCon con = new ErrorDialogCon();

            con.ErrorMsg = "用户不在线,消息发送失败";
        }
Пример #12
0
        public void onRecive_CalleeSetRemoteSdpCompleted(websocketMsgTemp <object> e)
        {
            string sendMachineId = e.sendMachineId;

            this.ControllerLogic.onRemoteClientSdpCompleted(sendMachineId);
        }
Пример #13
0
 public void onRecive_CutPeerConnection(websocketMsgTemp <object> e)
 {
     string remoteMachineId = e.sendMachineId;
 }