Results 1 to 3 of 3

Thread: How to Disconnect() a call with IceLib?

  1. #1
    Join Date
    Apr 2016
    Posts
    33

    How to Disconnect() a call with IceLib?

    I am having difficulty disconnecting an interaction. I am simply calling the `.Disconnect()` method on the Interaction object but nothing is happening. It could be how I am obtaining the interaction object giving an Id.


    Here is my code

    Code:
    public JsonpResult Disconnect(long interactionId)
    {
        var resource = new BaseResource();
    
        try
        {
            var interaction = GetInteraction(interactionId);
            interaction.Disconnect();
    
            resource.IsSuccess = true;
            resource.HttpCode = 200;
        }
        catch (Exception ex)
        {
            resource.Error = ex.Message;
            resource.InnerError = (ex.InnerException == null) ? "" : ex.InnerException.ToString();
            resource.HttpCode = (int)System.Net.HttpStatusCode.SeeOther;
        }
    
        return new JsonpResult(resource);
     }
    When the call in in "Proceeding" state, the request hangs on the `interaction.Disconnect()` until the other party picks up. But even then, the code proceed but it does not hang up the call.

    Here is how I fetch for the interaction giving the interactionId.

    Code:
            
    private Interaction GetInteraction(long interactionId)
    {
        var id = new InteractionId(interactionId);
        var interaction = GetInteractionManager().CreateInteraction(id);
    
        if (interaction == null)
        {
            throw new Exception("Unable to find the interaction");
        }
          
        return interaction;
    }
    What am I doing wrong here? How can I Disconnect() the call?
    Last edited by malhayek; November 29th, 2017 at 13:36.

  2. #2
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by malhayek View Post
    I am having difficulty disconnecting an interaction. I am simply calling the `.Disconnect()` method on the Interaction object but nothing is happening. It could be how I am obtaining the interaction object giving an Id.


    Here is my code

    Code:
    public JsonpResult Disconnect(long interactionId)
    {
        var resource = new BaseResource();
    
        try
        {
            var interaction = GetInteraction(interactionId);
            interaction.Disconnect();
    
            resource.IsSuccess = true;
            resource.HttpCode = 200;
        }
        catch (Exception ex)
        {
            resource.Error = ex.Message;
            resource.InnerError = (ex.InnerException == null) ? "" : ex.InnerException.ToString();
            resource.HttpCode = (int)System.Net.HttpStatusCode.SeeOther;
        }
    
        return new JsonpResult(resource);
     }
    When the call in in "Proceeding" state, the request hangs on the `interaction.Disconnect()` until the other party picks up. But even then, the code proceed but it does not hang up the call.

    Here is how I fetch for the interaction giving the interactionId.

    Code:
            
    private Interaction GetInteraction(long interactionId)
    {
        var id = new InteractionId(interactionId);
        var interaction = GetInteractionManager().CreateInteraction(id);
    
        if (interaction == null)
        {
            throw new Exception("Unable to find the interaction");
        }
          
        return interaction;
    }
    What am I doing wrong here? How can I Disconnect() the call?

    Your close change: var interaction = GetInteractionManager().CreateInteraction(id);
    To: var interaction = interactionManager.CreateInteraction(new InteractionId(id));

    I fell into this same trap once, it seems the overload for long does not work so you need to pass in an InteractionId object.

  3. #3
    Join Date
    Apr 2016
    Posts
    33
    I don't understand. My code works fine. However, it does not hangup the call until the call is picked up. In another word, when the call is "Proceeding" I can't disconnect it. But I can disconnected it when it connect.

    Here is the code the GetInteractionManager

    Code:
    private InteractionsManager InteractionsManager { get; set; }
    
    protected InteractionsManager GetInteractionManager()
    {
        if (InteractionsManager == null)
        {
            var session = ConnectionManager.GetSessionCapsule(GetDefaultServer()).Session;
            InteractionsManager = InteractionsManager.GetInstance(session);
        }
    
        if (InteractionsManager == null)
        {
            throw new Exception("Unable to create an Interaction Manager instance.");
        }
    
        return InteractionsManager;
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •