public void HandleMessage(CtiServiceSwitch @switch, Message message) { var connectMessage = message as ConnectMessage; if (connectMessage != null) { var device = @switch.Devices.FirstOrDefault(d => d.Id == connectMessage.Device.Id); if (device != null) { @switch.SendMessage(device, new SwitchMessage(SwitchMessageType.Disconnected)); } @switch.Devices.Add(connectMessage.Device); if (connectMessage.EnableGlobalSubscription) { @switch.GlobalSubscribers.Add(connectMessage.Device); } connectMessage.Device.Agent.State = SwitchAgentState.LoggedIn; connectMessage.Device.Agent.Device = connectMessage.Device; var agentStateMessage = new AgentStateMessage { State = connectMessage.Device.Agent.State, AgentId = connectMessage.Device.Agent.Id, DeviceId = connectMessage.Device.Id, }; @switch.SendMessage(connectMessage.Device, agentStateMessage); } }
private void notifyInteractionState(CtiServiceSwitch @switch, SwitchInteraction interaction, SwitchInteractionState state) { interaction.State = state; @switch.SendMessage(interaction.Agent.Device, new InteractionMessage { Interaction = interaction, Action = InteractionMessageAction.StateChanged }); }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var createInteractionMessage = message as CreateInteractionMessage; if (createInteractionMessage != null) { @switch.QueueInteraction(createInteractionMessage.Interaction); } }
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); } }
private void notifyAgentState(Device device, SwitchAgentState state, CtiServiceSwitch @switch) { var agentStateMessage = new AgentStateMessage { AgentId = device.Agent.Id, DeviceId = device.Id, State = state, }; @switch.SendMessage(device, agentStateMessage); }
private void initializeClient() { _client = new SwitchClient(new InstanceContext(this)); try { _client.Open(); (_client as ICommunicationObject).Faulted += CtiServiceController_Faulted; } catch (EndpointNotFoundException) { CtiServiceSwitch.Run(RightNowGlobalContext); initializeClient(); } }
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); } }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var disconnectMessage = message as SwitchMessage; if (disconnectMessage != null) { @switch.SendMessage(null, disconnectMessage); var device = @switch.Devices.FirstOrDefault(d => d.Id == disconnectMessage.DeviceId); if (device != null) { @switch.Devices.Remove(device); } } }
private SwitchClient initializeClient() { var client = new SwitchClient(new InstanceContext(this)); try { client.Open(); (client as ICommunicationObject).Faulted += CtiServiceController_Faulted; } catch (EndpointNotFoundException) { CtiServiceSwitch.Run(_rightNowContext); client = initializeClient(); } return(client); }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var switchMessage = message as SwitchMessage; if (switchMessage != null) { var device = @switch.Devices.FirstOrDefault(d => d.Id == switchMessage.DeviceId); var response = new SwitchStateMessage { Devices = new List <Device>(@switch.Devices) }; @switch.SendMessage(device, response); } }
private void notifyAcw(SwitchInteraction interaction, CtiServiceSwitch @switch) { //var agentStateMessage = new AgentStateMessage { // AgentId = interaction.Agent.Id, // DeviceId = interaction.Agent.Device.Id, // State = SwitchAgentState.WrapUp, //}; var agentStateMessage = new AgentStateMessage { AgentId = interaction.Agent.Id, DeviceId = interaction.Agent.Device.Id, State = SwitchAgentState.Available, }; @switch.SendMessage(interaction.Agent.Device, agentStateMessage); }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var stateMessage = message as AgentStateMessage; if (stateMessage != null) { var device = @switch.Devices.FirstOrDefault(d => d.Id == stateMessage.DeviceId && d.Agent.Id == stateMessage.AgentId); device.Agent.State = stateMessage.State; @switch.SendMessage(device, message); if (device.Agent.State == SwitchAgentState.Available) { @switch.AssignInteraction(device); } } }
public SimpleMessagingProvider(CtiServiceSwitch CtiServiceSwitch) { this.Switch = CtiServiceSwitch; }
public void HandleMessage(CtiServiceSwitch @switch, Message message) { var stateMessage = message as InteractionRequestMessage; if (stateMessage != null) { var interaction = @switch.Interactions.FirstOrDefault(i => i.Id == stateMessage.InteractionId); switch (stateMessage.Action) { case InteractionRequestAction.Accept: if (interaction.Agent != null) { sInteraction = interaction; } else { interaction.Agent = sInteraction.Agent; } interaction.Agent.State = SwitchAgentState.HandlingInteraction; notifyAgentState(interaction.Agent.Device, SwitchAgentState.HandlingInteraction, @switch); interaction.State = SwitchInteractionState.Active; @switch.SendMessage(interaction.Agent.Device, new InteractionMessage { Interaction = interaction, Action = InteractionMessageAction.Assigned }); break; case InteractionRequestAction.Hold: notifyInteractionState(@switch, interaction, SwitchInteractionState.Held); break; case InteractionRequestAction.Conferenced: notifyInteractionState(@switch, interaction, SwitchInteractionState.Conferenced); break; case InteractionRequestAction.Consulting: notifyInteractionState(@switch, interaction, SwitchInteractionState.Consulting); break; case InteractionRequestAction.Retrieve: notifyInteractionState(@switch, interaction, SwitchInteractionState.Active); break; case InteractionRequestAction.Disconnect: interaction.State = Providers.CtiServiceProvider.SwitchInteractionState.Disconnected; notifyInteractionState(@switch, interaction, SwitchInteractionState.Disconnected); //interaction.Agent.State = SwitchAgentState.Available; //notifyAgentState(interaction.Agent.Device, SwitchAgentState.Available, @switch); break; case InteractionRequestAction.Complete: if (interaction.State != SwitchInteractionState.Disconnected) { interaction.Agent.State = SwitchAgentState.Available; notifyAgentState(interaction.Agent.Device, SwitchAgentState.Available, @switch); } interaction.Agent.Interactions.Remove(interaction); @switch.Interactions.Remove(interaction); notifyInteractionState(@switch, interaction, SwitchInteractionState.Completed); break; default: break; } } }