public void HandleMessage(CtiServiceSwitch @switch, Message message) { var interactionTransferMessage = message as InteractionTransferMessage; if (interactionTransferMessage != null) { var interaction = @switch.Interactions.FirstOrDefault(i => i.Id == interactionTransferMessage.InteractionId); var transferInteraction = new SwitchInteraction { Id = Guid.NewGuid(), State = SwitchInteractionState.Queued, SourceAddress = interaction.SourceAddress, ReferenceId = interaction.ReferenceId, Queue = interaction.Queue, Properties = interaction.Properties, Type = interaction.Type, ConferencedCall = interaction.ConferencedCall }; var originalTransfers = transferInteraction.Properties.Where(p => p.Key.StartsWith("OriginalInteraction-")).Count(); transferInteraction.Properties.Add(string.Format("OriginalInteraction-{0}", originalTransfers), interaction.Id.ToString()); if (interactionTransferMessage.TargetAddress == "queue") { @switch.QueueInteraction(transferInteraction); } else { var device = @switch.Devices.FirstOrDefault(d => d.Address == interactionTransferMessage.TargetAddress); if (device != null) { @switch.Interactions.Add(transferInteraction); @switch.AssignInteraction(device, transferInteraction); } } notifyInteractionState(@switch, interaction, SwitchInteractionState.Disconnected); interaction.Agent.State = SwitchAgentState.WrapUp; notifyAcw(interaction, @switch); } var deviceInfoMessage = message as GetDeviceInfoMessage; if (deviceInfoMessage != null) { var device = @switch.Devices.FirstOrDefault(d => d.Id == deviceInfoMessage.DeviceId); var targetDevice = @switch.Devices.FirstOrDefault(d => d.Id == deviceInfoMessage.TargetDeviceId); var response = new DeviceInfoMessage { TargetDevice = targetDevice }; @switch.SendMessage(device, response); } }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var deviceInfoMessage = message as GetDeviceInfoMessage; if (deviceInfoMessage != null) { var device = @switch.Devices.FirstOrDefault(d => d.Id == deviceInfoMessage.DeviceId); var targetDevice = @switch.Devices.FirstOrDefault(d => d.Id == deviceInfoMessage.TargetDeviceId); var response = new DeviceInfoMessage { TargetDevice = targetDevice }; @switch.SendMessage(device, response); } }
private void updateDeviceInfo(DeviceInfoMessage message) { Application.Current.Dispatcher.Invoke(new Action(() => { var device = Devices.FirstOrDefault(d => d.Id == message.TargetDevice.Id); if (device == null) { Devices.Add(message.TargetDevice); } else { device.Address = message.TargetDevice.Address; device.Agent.Interactions = message.TargetDevice.Agent.Interactions; device.Agent.State = message.TargetDevice.Agent.State; device.Agent.Device = device; } })); }
protected void FireDeviceInfoMessage(string msg) { DeviceInfoMessage?.Invoke(this, msg); }