コード例 #1
0
        public bool MakeCall(string dest)
        {
            //发起通话时,将RemoteNumber设置为目标号码
            RemoteNumber = dest;
            HandsetReqMakeCallMsg msg = new HandsetReqMakeCallMsg {
                DestUri = dest
            };

            if (_handsetprocess.SendMessage(msg))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        private void OnReceiveMsg(object sender, ReceivedMessageEventArgs args)
        {
            HandsetReqMsg request = JsonConvert.DeserializeObject <HandsetReqMsg>(args.Message);

            if (request == null)
            {
                return;
            }

            switch (request.MsgRequestCode)
            {
            case HANDSETMSG_REQ_CODE.MSG_REQ_RUN:
                HandsetReqUAStartMsg run = JsonConvert.DeserializeObject <HandsetReqUAStartMsg>(args.Message);
                if (run != null)
                {
                    RunUADelegate d = new RunUADelegate(RunUA);
                    this.BeginInvoke(d, new object[] { run.CaptureDevice, run.PlaybackDevice });
                }
                break;

            case HANDSETMSG_REQ_CODE.MSG_REQ_ADDACCOUNT:
                HandsetReqAddAccountMsg account = JsonConvert.DeserializeObject <HandsetReqAddAccountMsg>(args.Message);
                if (account != null)
                {
                    AddAccountDelegate d = new AddAccountDelegate(AddAccount);
                    this.BeginInvoke(d, new object[] { account.User, account.Password, account.Domain, account.Proxy, account.IsReg, account.IsAutoAnswer });
                }
                break;

            case HANDSETMSG_REQ_CODE.MSG_REQ_ANSWER:
            {
                AnswerDelegate d = new AnswerDelegate(Answer);
                this.BeginInvoke(d);
            }
            break;

            case HANDSETMSG_REQ_CODE.MSG_REQ_HANGUP:
            {
                HangupDelegate d = new HangupDelegate(Hangup);
                this.BeginInvoke(d);
            }
            break;

            case HANDSETMSG_REQ_CODE.MSG_REQ_MAKECALL:
                HandsetReqMakeCallMsg call = JsonConvert.DeserializeObject <HandsetReqMakeCallMsg>(args.Message);
                if (call != null)
                {
                    MakeCallDelegate d = new MakeCallDelegate(MakeCall);
                    this.BeginInvoke(d, new object[] { call.DestUri });
                }
                break;

            case HANDSETMSG_REQ_CODE.MSG_REQ_RECORDINGDIRCHANGED:
                //更改录音文件的存放路径
                HandsetReqRecordingDirChangedMsg recordingDir = JsonConvert.DeserializeObject <HandsetReqRecordingDirChangedMsg>(args.Message);
                if (recordingDir != null)
                {
                    _recordDir = recordingDir.newRecordingDir;
                }
                break;
            }
        }