I am trying to use the IceLib in a Asp.Net MVC 5 Environment. So far, I am able to interact with the interaction successful. With an issue in the queue watching process.
To watch my queue, I create a WebSocket connection between the browser and the server using
SignalR package. Inside my SignalR Hub, I call the following code when the client connects to the server so when a interaction is added, changes or removed from the queue, the browser is notified.
private void WatchMyInteractions(ViewCompanyServer dialerServer)
{
var interactionManager = GetInteractionManager(ConnectionManager);
QueueId queueId = new QueueId(QueueType.MyInteractions, GetIdentity.Name);
InteractionQueue _interactionQueue = new InteractionQueue(interactionManager, queueId);
_interactionQueue.InteractionAdded += QueueInteractionAdded;
_interactionQueue.InteractionChanged += QueueInteractionChanged;
_interactionQueue.InteractionRemoved += QueueInteractionRemoved;
_interactionQueue.StartWatching(GetAttributes());
}
public void QueueInteractionAdded(object sender, InteractionAttributesEventArgs e)
{
// This line sends the interaction attributes to the browser
SendInteraction(e.Interaction, "Added"); // PROBLEM - this code hangs until the recipient pick up before the message is sent to the browser.
}
public void QueueInteractionChanged(object sender, InteractionAttributesEventArgs e)
{
// This line sends the interaction attributes to the browser
SendInteraction(e.Interaction, "Changed");
}
public void QueueInteractionRemoved(object sender, InteractionEventArgs e)
{
// This line sends the interaction attributes to the browser
SendInteraction(e.Interaction, "Removed");
}
protected void SendInteraction(Interaction interaction, string type)
{
if (interaction != null)
{
// This just create a new GenericModel with the attributes that are being watched.
var obj = new InteractionQueueGenericModel(interaction, type);
// This line converts the object to json then send it to the browser.
Clients.User(GetIdentity.Name).updatePhone(JsonConvert.SerializeObject(obj));
}
}
However, I am running into a problem when making the call while watching my Queue. When the call is made using the code below, the application waits/hangs until the other-party/recipient picks up before the `SendInteraction(e.Interaction, "Added")` is processed. So the browser, won't know that a call is being made "or the it does not know that e.Interaction.State == "Proceeding" " until after the SendInteraction() method is called.
In another words, the `QueueInteractionAdded()` method gets called, but it hang on the `SendInteraction()` line until the other party picks up before the message is sent to the browser. Then after that, any change to the interaction the user is notified correctly.
I currency make my calls using following code
InteractionsManager.GetInstance(session).MakeCall(new CallInteractionParameters("800-000-4444"));
How can I prevent the app from having to wait on the `SendInteraction(e.Interaction, "Added")` line?
What am I doing wrong here?