Eric Scherrer Eric Scherrer -4 years ago 139
C# Question

Calling IInteractionVoice.Release() not releasing (hanging up) the current call in a Workspace Desktop Edition custom module

I have a requirement to hang up the current phone call programmatically in Genesys Workspace Desktop edition. Here is what I have:

public class SomeService
{
private readonly IEnterpriseServiceProvider _esp;

public SomeService(IEnterpriseServiceProvider esp)
{
_esp = esp;
}

public void HangupCurrentCall()
{
var iv = _esp.Resolve<IInteractionVoice>();

iv.Release();
}
}


The code above is executing with no error, but the call is not being hung up.

Answer Source

You can't hangup current call just from enterprise service. WDE providing API for that. You can check from developer guide document. Actually you have two options to achieve this. First way using WDE API command calls. Second way using universal SDK (PSDK) to hangup current call. First of all you need to collect current call's interactionId. After that can call a command like that,

commandManager.CommandsByName["InteractionVoiceReleaseCall"].Insert(0, new CommandActivator()
            {
                CommandType = typeof(CustomCommand.ReleaseCall),
                Name = "InteractionVoiceReleaseCall"
            });     

You can find all commands list from WDE api guide. On your command type (class) you must return boolean. If you return false, its ok to continue, sending true like break the command.

Or you can directly execute a command like this;

IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("CommandParameter", interaction);
parameters.Add("Reasons", reasons);
parameters.Add("Extensions", extensions);
commandManager.GetChainOfCommandByName("InteractionVoiceReleaseCall").Execute();

As a SDK certificated developer, i always prefer PSDK(universal genesys sdk). You can retrieve current SIP Server connection and send request to it. Like this code block

IChannelService channelService = agent.EntrepriseService.Resolve<IChannelService>("channelService");
IClientChannel tServerChannel = channelService.ListChannels<Genesyslab.Platform.Voice.Protocols.TServerProtocol>().FirstOrDefault();

channelService.RegisterEvents(tServerChannel, new Action<Genesyslab.Enterprise.Model.Channel.IClientChannel>(ChannelEvent));

TServerProtocol tServerProtocol = tServerChannel.Protocol as TServerProtocol;

After this you have current connection on tserverPorotocol object. Then you can send a request to SIP Server.

Like this:

Genesyslab.Platform.Voice.Protocols.TServer.Requests.Voice.RequestReleaseCall releaseCall = Genesyslab.Platform.Voice.Protocols.TServer.Requests.Voice.RequestReleaseCall.Create();
releaseCall.ThisDN = "7000"; //(for example)(you can retrieve agent's DN from agent object)
releaseCall.ConnID = interaction.ConnectionId     // you can retrieve from interactionhandler event.

 tServerProtocol.Send(releaseCall);
 //or  tServerProtocol.Request(releaseCall); for async request. request return a ack message from the server.

I tried to explain basics. I hope its helpful. If you got a question about sip or etc. please let me know.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download