public void RequestOnNat() { //CommandMsg msg = new CommandMsg() { // cmd = USRSTRUCTS.ENABLE_NAT_CALL_RECORD_REQ, // type = USRSTRUCTS.TYPE_COUPLEPHONE, // direct = USRSTRUCTS.DIRECT_OUTGOING, // from_ext = CoupleModeInfo.userid //}; CommandMsg msg = new CommandMsg() { cmd = USRSTRUCTS.SEND_RECORD_DUMMY_DATA, from_ext = CoupleModeInfo.userid }; byte[] bytes = util.GetBytes(msg); try { client.Send(bytes, bytes.Length); } catch (SocketException ex) { util.WriteLog(ex.ErrorCode, ex.Message.ToString()); } }
void DoItFromSocketMessage(byte[] buffer) { CommandMsg msg = util.GetObject <CommandMsg>(buffer); //if (msg.cmd == USRSTRUCTS.ENABLE_NAT_CALL_RECORD_RES) //{ // timer = new System.Timers.Timer(); // timer.Interval = 40000; // timer.Elapsed += Sessiontimer_Elapsed; // timer.Start(); // if (RecordRequestedSuccessOnNatEvent != null) // RecordRequestedSuccessOnNatEvent(this, msg); // return; //} RecordInfo_t recInfo = util.GetObject <RecordInfo_t>(buffer); int nDataSize = recInfo.size - 12; if (nDataSize != 80 && nDataSize != 160 && nDataSize != 240 && nDataSize != 10 && nDataSize != -12) { return; } // util.WriteLog(string.Format("seq:{0}, ext:{1}, peer:{2}, isExtension:{3}, size:{4}, bytesLength:{5}", recInfo.seq, recInfo.extension, recInfo.peer_number, recInfo.isExtension, recInfo.size - 12, recInfo.voice.Length)); this.StackRtp2Instance(recInfo); }
private void KeepSession() { //CommandMsg msg = new CommandMsg() //{ // cmd = USRSTRUCTS.SEND_RECORD_DUMMY_DATA, // type = USRSTRUCTS.TYPE_COUPLEPHONE, // from_ext = CoupleModeInfo.userid, // userid = CoupleModeInfo.userid //}; CommandMsg msg = new CommandMsg() { cmd = USRSTRUCTS.SEND_RECORD_DUMMY_DATA, from_ext = CoupleModeInfo.userid }; byte[] bytes = util.GetBytes(msg); try { client.Send(bytes, bytes.Length); } catch (SocketException e) { util.WriteLog(e.ErrorCode, e.Message.ToString()); } }
public void Send(byte st) { try { CommandMsg msg = GetCmdMsg(st); byte[] buffer = util.getBytes(sendMsg); s.SendTo(buffer, ServerEndPoint); } catch (System.Net.Sockets.SocketException ex) { throw ex; } }
public void DropCall(CallList call) { CommandMsg msg = this.GetCommandMsg(USRSTRUCTS.DROP_CALL_REQ, call); byte[] bytes = util.GetBytes(msg); try { client.Send(bytes, bytes.Length); } catch (SocketException ex) { util.WriteLog(ex.ErrorCode, ex.Message.ToString()); } }
public void PickupCall(string number) { CommandMsg msg = this.GetCommandMsg(USRSTRUCTS.PICKUP_CALL_REQ, number); byte[] bytes = util.GetBytes(msg); try { client.Send(bytes, bytes.Length); } catch (SocketException ex) { util.WriteLog(ex.ErrorCode, ex.Message.ToString()); } }
public void RecordStartRequestOnNat(string number) { CommandMsg msg = this.GetCommandMsg(USRSTRUCTS.ENABLE_NAT_CALL_RECORD_REQ, number); byte[] bytes = util.GetBytes(msg); try { client.Send(bytes, bytes.Length); } catch (SocketException ex) { util.WriteLog(ex.ErrorCode, ex.Message.ToString()); } }
public void Register() { CommandMsg _msg = GetCommandMsg(USRSTRUCTS.REGISTER_REQ); byte[] bytes = util.GetBytes(_msg); try { client.Send(bytes, bytes.Length); } catch (SocketException ex) { util.WriteLog(ex.ErrorCode, ex.Message.ToString()); } }
public CommandMsg GetCmdMsg(byte st) { CommandMsg rtnMsg = new CommandMsg(); switch (st) { case SocketStruct.REGISTER_REQ: rtnMsg.cmd = SocketStruct.REGISTER_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case SocketStruct.UNREGISTER_REQ: rtnMsg.cmd = SocketStruct.UNREGISTER_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case SocketStruct.PICKUP_CALL_REQ: break; case SocketStruct.MAKE_CALL_REQ: rtnMsg.cmd = SocketStruct.MAKE_CALL_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.from_ext = From_Ext; rtnMsg.to_ext = To_Ext; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; break; } return(rtnMsg); }
public CommandMsg GetCommandMsg(byte st, string toext) { CommandMsg rtnMsg = new CommandMsg(); switch (st) { case USRSTRUCTS.REGISTER_REQ: rtnMsg.cmd = USRSTRUCTS.REGISTER_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case USRSTRUCTS.UNREGISTER_REQ: rtnMsg.cmd = USRSTRUCTS.UNREGISTER_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case USRSTRUCTS.PICKUP_CALL_REQ: break; case USRSTRUCTS.MAKE_CALL_REQ: rtnMsg.cmd = USRSTRUCTS.MAKE_CALL_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.from_ext = UserId; rtnMsg.to_ext = toext; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; break; } return(rtnMsg); }
private void SendReceiveSocketMsg() { try { ////srvEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), ServerPort); s = new Socket(ServerEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); //sendMsg = GetCmdMsg(USRSTRUCTS.REGISTER_REQ); //byte[] buffer = USRSTRUCTS.getBytes(sendMsg); ////s.SendTo(buffer, buffer.Length, SocketFlags.None, serverEndPoint); //s.SendTo(buffer, ServerEndPoint); int bytes = 0; rcvMsg = new CommandMsg(); byte[] rcvBuffer = util.getBytes(rcvMsg); while (true) { bytes = s.ReceiveFrom(rcvBuffer, ref remoteEndPoint); if (bytes > 0) { rcvMsg = (CommandMsg)util.getObject(rcvBuffer); //DoItFromSocketMessage(rcvMsg, sendMsg); UDPSocketReceiveCommandMessage(this, rcvMsg); } } } catch (SocketException se) { //MessageBox.Show(se.ErrorCode + " : " + se.Message); } }
private void Client_EnableRecordRequestOnNatSuccessEvent(object obj, CommandMsg msg) { recorder = new RTPRecorderCouple(21011, CONNECTED_MODE.NAT); IsRecording = true; this.SetMessage(Application.Current.FindResource("ISRECORDING").ToString()); }
public CommandMsg GetCommandMsg(byte st, CallList call) { CommandMsg msg = new CommandMsg() { cmd = st }; switch (st) { case USRSTRUCTS.REGISTER_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.userid = string.Empty; break; case USRSTRUCTS.UNREGISTER_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.userid = string.Empty; break; case USRSTRUCTS.MAKE_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.userid = CoupleModeInfo.userid; break; case USRSTRUCTS.DROP_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; break; case USRSTRUCTS.PICKUP_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_INCOMING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; // msg.userid = CoupleModeInfo.userid; break; case USRSTRUCTS.TRANSFER_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.HOLD_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.ACTIVE_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.ENABLE_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; case USRSTRUCTS.ENABLE_NAT_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; case USRSTRUCTS.DISABLE_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; } return(msg); }
public CommandMsg GetCommandMsg(byte st) { CommandMsg rtnMsg = new CommandMsg(); switch (st) { case SocketStruct.REGISTER_REQ: rtnMsg.cmd = SocketStruct.REGISTER_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case SocketStruct.UNREGISTER_REQ: rtnMsg.cmd = SocketStruct.UNREGISTER_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case SocketStruct.PICKUP_CALL_REQ: break; case SocketStruct.MAKE_CALL_REQ: rtnMsg.cmd = SocketStruct.MAKE_CALL_REQ; rtnMsg.type = SocketStruct.TYPE_COUPLEPHONE; rtnMsg.from_ext = From_Ext; rtnMsg.to_ext = To_Ext; rtnMsg.direct = SocketStruct.DIRECT_OUTGOING; break; } return rtnMsg; }
private void Client_DropCallSuccessEvent(object obj, CommandMsg msg) { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { btnCall.Content = "☎"; btnCall.ToolTip = "Call"; })); }
public CommandMsg GetCommandMsg(byte st, string toext) { CommandMsg rtnMsg = new CommandMsg(); switch (st) { case USRSTRUCTS.REGISTER_REQ: rtnMsg.cmd = USRSTRUCTS.REGISTER_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case USRSTRUCTS.UNREGISTER_REQ: rtnMsg.cmd = USRSTRUCTS.UNREGISTER_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; rtnMsg.from_ext = UserId; //rtnMsg.to_ext = to_ext; rtnMsg.userid = string.Empty; break; case USRSTRUCTS.PICKUP_CALL_REQ: break; case USRSTRUCTS.MAKE_CALL_REQ: rtnMsg.cmd = USRSTRUCTS.MAKE_CALL_REQ; rtnMsg.type = USRSTRUCTS.TYPE_COUPLEPHONE; rtnMsg.from_ext = UserId; rtnMsg.to_ext = toext; rtnMsg.direct = USRSTRUCTS.DIRECT_OUTGOING; break; } return rtnMsg; }
private void Couplemodeclient_CallProceedingEvent(object obj, CommandMsg msg) { }
private void Client_TransferCallFailEvent(object obj, CommandMsg msg) { }
private void Client_TransferCallSuccessEvent(object obj, CommandMsg msg) { behavoir = BEHAVIOR_STATES.NONE; }
private void Client_HoldCallFailEvent(object obj, CommandMsg msg) { }
private void Client_HoldCallSuccessEvent(object obj, CommandMsg msg) { }
private void Client_ActiveCallFailEvent(object obj, CommandMsg msg) { }
private void Client_ActiveCallSuccessEvent(object obj, CommandMsg msg) { }
private void Client_CallConnectedEvent(object obj, CommandMsg msg) { if (curCall == null) return; if (curCall.Cust_Idx > 0) { SetMessage(string.Format(Application.Current.FindResource("MSG_CALL_STATES_CONNECTED2").ToString(), curCall.Name)); } else { SetMessage(Application.Current.FindResource("MSG_CALL_STATES_CONNECTED").ToString()); } this.UIChanging(msg.status); }
private void Couplemodeclient_CallRingInEvent(object obj, CommandMsg msg) { if (curCall != null) return; curCall = new CallList() { Direction = 1, Cust_Tel = msg.from_ext, Startdate = DateTime.Now, ext = msg.from_ext, to_ext = msg.to_ext }; Customer cust = pb.GetCustomerByTel(msg.from_ext); string strmsg = string.Empty; if (cust.Idx < 1) { pb.CUSTOMERSTATE = CUSTOMER_STATE.ADD; cust.Group_Idx = 0; cust.Cellular = msg.from_ext; strmsg = Application.Current.FindResource("MSG_CALL_IN").ToString(); } else { pb.CUSTOMERSTATE = CUSTOMER_STATE.MODIFY; curCall.Cust_Idx = cust.Idx; curCall.Name = cust.Name; strmsg = string.Format(Application.Current.FindResource("MSG_CALL_IN2").ToString(), cust.Name); } SetMessage(strmsg); SetNumber(msg.from_ext); // CallLists calllists = new CallLists(); // calllists.add(curCall); Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { if (startpopup) { if (pb == null) { pb = new PhoneBook(); pb.Owner = this; } // pb.Show(); } SearchCondition1 con = new SearchCondition1(); con.StartDate = pb.sdate.Value; con.EndDate = pb.edate.Value; con.Number = string.IsNullOrEmpty(pb.txtNumber.Text.Trim()) == false ? string.Format("%{0}%", pb.txtNumber.Text.Trim()) : string.Empty; if (pb.calls == null) { pb.calls = new CallLists(con); pb.dgCallList.ItemsSource = pb.calls; } pb.calls.add(curCall); if (pb.Visibility == Visibility.Collapsed || pb.Visibility == Visibility.Hidden) { pb.tabs.SelectedIndex = 1; pb.dgridCustCallList.ItemsSource = pb.GetCallListByCustIdx(cust.Idx, curCall.Cust_Tel); pb.btnCustMemo.Visibility = Visibility.Visible; pb.FlyCustomer = cust; pb.flyCustomer.Header = Application.Current.FindResource("PB_FLYOUT_TITLE_CUST_INFO").ToString(); pb.flyCustomer.IsOpen = true; if (startpopup) { pb.Visibility = Visibility.Visible; } } else { pb.tabs.SelectedIndex = 1; pb.dgridCustCallList.ItemsSource = pb.GetCallListByCustIdx(cust.Idx, curCall.Cust_Tel); pb.btnCustMemo.Visibility = Visibility.Visible; pb.FlyCustomer = cust; pb.flyCustomer.Header = Application.Current.FindResource("PB_FLYOUT_TITLE_CUST_INFO").ToString(); if (startpopup) { pb.flyCustomer.IsOpen = true; } } })); this.UIChanging(msg.status); }
private void Client_PickupCallSuccessEvent(object obj, CommandMsg msg) { }
private void Couplemodeclient_CallInvitingEvent(object obj, CommandMsg msg) { }
private void SendReceiveSocketMsg() { try { ////srvEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), ServerPort); s = new Socket(ServerEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); //sendMsg = GetCmdMsg(SocketStruct.REGISTER_REQ); //byte[] buffer = SocketStruct.getBytes(sendMsg); ////s.SendTo(buffer, buffer.Length, SocketFlags.None, serverEndPoint); //s.SendTo(buffer, ServerEndPoint); int bytes = 0; rcvMsg = new CommandMsg(); byte[] rcvBuffer = util.getBytes(rcvMsg); while (true) { bytes = s.ReceiveFrom(rcvBuffer, ref remoteEndPoint); if (bytes > 0) { rcvMsg = (CommandMsg)util.getObject(rcvBuffer); //DoItFromSocketMessage(rcvMsg, sendMsg); UDPSocketReceiveCommandMessage(this, rcvMsg); } } } catch (SocketException se) { //MessageBox.Show(se.ErrorCode + " : " + se.Message); } }
private void Client_EnableRecordRequestSuccessEvent(object obj, CommandMsg msg) { if (msg.status == USRSTRUCTS.STATUS_NAT_SUCCESS) { client.RecordStartRequestOnNat(curCall.Cust_Tel); // recorder = new RTPRecorderCouple(msg.port, CONNECTED_MODE.NAT); } else { // recorder = new RTPRecorderCouple(msg.port, CONNECTED_MODE.PUBLIC); recorder = new RTPRecorderCouple(CONNECTED_MODE.PUBLIC); } // recorder = new RTPRecorderCouple(msg.port, connectedmode); // client.RecordStartRequestOnNat(curCall.Cust_Tel); IsRecording = true; this.SetMessage(Application.Current.FindResource("ISRECORDING").ToString()); }
private void Couplemodeclient_RegSuccessNatEvent(object obj, CommandMsg msg) { if (!client.IsRegistered) { client.RegTimerInit(); ConnectSuccess(msg); client.IsRegistered = true; } connectedmode = CONNECTED_MODE.NAT; }
private void ConnectSuccess(CommandMsg msg) { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { if (msg.status == 0 || msg.status == 99) { this.Title = this.Title + " (" + msg.from_ext + ")"; img_antena.ToolTip = Application.Current.FindResource("TOOTIP_MAIN_ANTENA_ON"); img_antena.Style = (Style)Application.Current.FindResource("antena_on"); } else { this.Title = Application.Current.FindResource("MSG_MAIN_TITLE").ToString(); img_antena.ToolTip = Application.Current.FindResource("TOOTIP_MAIN_ANTENA_OFF"); img_antena.Style = (Style)Application.Current.FindResource("antena_off"); } })); }
private void Couplemodeclient_RegSuccessEvent(object obj, CommandMsg msg) { if (!client.IsRegistered) { ConnectSuccess(msg); client.IsRegistered = true; } connectedmode = CONNECTED_MODE.PUBLIC; }
private void DoItFromSocketMessage(byte[] buffer) { CommandMsg rcvMsg = util.GetObject <CommandMsg>(buffer); util.WriteStructVal(rcvMsg); if (rcvMsg.cmd == USRSTRUCTS.SMS_SEND_REQ || rcvMsg.cmd == USRSTRUCTS.SMS_INFO_REQ || rcvMsg.cmd == USRSTRUCTS.SMS_RECV_REQ || rcvMsg.cmd == USRSTRUCTS.SMS_SEND_RES || rcvMsg.cmd == USRSTRUCTS.SMS_INFO_RES || rcvMsg.cmd == USRSTRUCTS.SMS_RECV_RES) { DoItForSMS(buffer); return; } switch (rcvMsg.cmd) { case USRSTRUCTS.REGISTER_RES: if (rcvMsg.status == USRSTRUCTS.STATUS_SUCCESS) { // 성공 if (RegSuccessEvent != null) { RegSuccessEvent(this, rcvMsg); } } else if (rcvMsg.status == USRSTRUCTS.STATUS_FAIL) { // 실패 if (RegFailEvent != null) { RegFailEvent(this, rcvMsg); } } else { // 성공 NAT if (RegSuccessNatEvent != null) { RegSuccessNatEvent(this, rcvMsg); } } break; case USRSTRUCTS.UNREGISTER_RES: if (UnRegSuccessEvent != null) { UnRegSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.MAKE_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (MakeCallSuccessEvent != null) { MakeCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (MakeCallFailEvent != null) { MakeCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.DROP_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (DropCallSuccessEvent != null) { DropCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (DropCallFailEvent != null) { DropCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.PICKUP_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (PickupCallSuccessEvent != null) { PickupCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (PickupCallFailEvent != null) { PickupCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.TRANSFER_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (TransferCallSuccessEvent != null) { TransferCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (TransferCallFailEvent != null) { TransferCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.HOLD_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (HoldCallSuccessEvent != null) { HoldCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (HoldCallFailEvent != null) { HoldCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.ACTIVE_CALL_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (ActiveCallSuccessEvent != null) { ActiveCallSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (ActiveCallFailEvent != null) { ActiveCallFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.ENABLE_CALL_RECORD_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: case USRSTRUCTS.STATUS_NAT_SUCCESS: if (EnableRecordRequestSuccessEvent != null) { EnableRecordRequestSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (EnableRecordRequestFailEvent != null) { EnableRecordRequestFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.ENABLE_NAT_CALL_RECORD_RES: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_SUCCESS: if (EnableRecordRequestOnNatSuccessEvent != null) { EnableRecordRequestOnNatSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_FAIL: default: if (EnableRecordRequestOnNatFailEvent != null) { EnableRecordRequestOnNatFailEvent(this, rcvMsg); } break; } break; case USRSTRUCTS.DISABLE_CALL_RECORD_RES: if (DisableRecordRequestSuccessEvent != null) { DisableRecordRequestSuccessEvent(this, rcvMsg); } break; case USRSTRUCTS.CALL_STATUS: switch (rcvMsg.status) { case USRSTRUCTS.STATUS_CALL_INVITING: if (CallInvitingEvent != null) { CallInvitingEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_PROCEEDING: if (CallProceedingEvent != null) { CallProceedingEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_RINGING: if (rcvMsg.direct == USRSTRUCTS.DIRECT_INCOMING) { if (CallRingInEvent != null) { CallRingInEvent(this, rcvMsg); } } else if (rcvMsg.direct == USRSTRUCTS.DIRECT_OUTGOING) { if (CallRingOutEvent != null) { CallRingOutEvent(this, rcvMsg); } } break; case USRSTRUCTS.STATUS_CALL_CONNECTED: if (CallConnectedEvent != null) { CallConnectedEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_NO_ANSWER: if (CallConnectedEvent != null) { CallConnectedEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_FORBIDDEN: if (CallFobidenEvent != null) { CallFobidenEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_BUSY: if (CallBusyEvent != null) { CallBusyEvent(this, rcvMsg); } break; case USRSTRUCTS.STATUS_CALL_TERMINATED: if (CallTerminatedEvent != null) { CallTerminatedEvent(this, rcvMsg); } break; } break; default: break; } }
private void Couplemodeclient_CallTerminatedEvent(object obj, CommandMsg msg) { SetMessage(string.Empty); SetNumber(string.Empty); if (callstate == CALL_STATES.CONNECTED) { //CallLists calllist = new CallLists(); //curCall.Enddate = DateTime.Now; //calllist.modify(curCall); Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { if (pb.calls == null) pb.calls = new CallLists(); curCall.Enddate = DateTime.Now; try { pb.calls.modify(curCall); CallList cl = pb.dgridCustCallList.SelectedItem as CallList; if (cl == null) { var items = pb.dgridCustCallList.ItemsSource as CallLists; cl = items.FirstOrDefault(x => x.Idx == curCall.Idx); } if (cl != null) cl.Enddate = curCall.Enddate; cl = pb.dgCallList.SelectedItem as CallList; if (cl == null) { var items = pb.dgCallList.ItemsSource as CallLists; cl = items.FirstOrDefault(x => x.Idx == curCall.Idx); } if (cl != null) cl.Enddate = curCall.Enddate; } catch (FbException e) { util.WriteLog(e.ErrorCode, e.Message); } })); } if (recorder != null) { recorder.Close(); recorder.Dispose(); recorder = null; IsRecording = false; } if (curCall != null) curCall = null; this.UIChanging(msg.status); }
private void Couplemodeclient_CallFobidenEvent(object obj, CommandMsg msg) { }
private void Client_PickupCallFailEvent(object obj, CommandMsg msg) { }
private void Client_DisableRecordRequestSuccessEvent(object obj, CommandMsg msg) { if (recorder != null) { recorder.Close(); recorder.Dispose(); recorder = null; } IsRecording = false; this.SetMessage(Application.Current.FindResource("ISNOTRECORDING").ToString()); }
private void Couplemodeclient_UnRegSuccessEvent(object obj, CommandMsg msg) { SetMessage(Application.Current.FindResource("MSG_UNREG_SUCCESS").ToString()); }
public CommandMsg GetCommandMsg(byte st, CallList call) { CommandMsg msg = new CommandMsg() { cmd = st }; switch (st) { case USRSTRUCTS.REGISTER_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.userid = string.Empty; break; case USRSTRUCTS.UNREGISTER_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.userid = string.Empty; break; case USRSTRUCTS.MAKE_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.userid = CoupleModeInfo.userid; break; case USRSTRUCTS.DROP_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; break; case USRSTRUCTS.PICKUP_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_INCOMING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; // msg.userid = CoupleModeInfo.userid; break; case USRSTRUCTS.TRANSFER_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.HOLD_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.ACTIVE_CALL_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.userid = CoupleModeInfo.userid; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = localport; break; case USRSTRUCTS.ENABLE_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; case USRSTRUCTS.ENABLE_NAT_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; case USRSTRUCTS.DISABLE_CALL_RECORD_REQ: msg.type = USRSTRUCTS.TYPE_COUPLEPHONE; msg.direct = USRSTRUCTS.DIRECT_OUTGOING; msg.from_ext = CoupleModeInfo.userid; msg.to_ext = call.to_ext; msg.ip = DistinguishIpBlock.IpAddress2Int(); msg.port = 21010; break; } return msg; }