I’m using a C#/NET library to implement my ARI conference app.
I’m implementing authentication prior to adding a conference user into a conference.
If a user fails to authenticate then it should play a sound and fire the StasisEnd event / Hangup.
If the auth function AddUser returns false then I get an endless loop of the playback sound.
If I force hangup with: Client.Channels.Hangup(e.Channel.Id); in the OnStasisEndEvent function like below, the app hangs up the call before the sound is done playing.
private static void c_OnStasisEndEvent(object sender, StasisEndEvent e)
{
Client.Channels.Hangup(e.Channel.Id); //here
if (e.Application != AppConfig.AppName) return;
var conf = Conference.Conferences.SingleOrDefault(x => x.ConferenceUsers.Any(c => c.Channel.Id == e.Channel.Id));
if (conf == null) return;
conf.RemoveUser(e.Channel.Id);
}
AddUser:
public bool AddUser(Channel c)
{
..............
else //if there aren't any conferences, play audio
{
PlayFile("no-empty-conferences", c.Id);
PlayFile("pls-try-call-later", c.Id);
addUser = false;
}
return addUser;
}
What can I do so the playback sound completes then hangup call ?