Ejemplo n.º 1
0
        private async void OnClientConnect(object sender, ClientConnectedEventArgs e)
        {
            ITcpChannel channel    = e.Channel;
            FreeSwitch  freeSwitch = new FreeSwitch(ref channel);

            try {
                var added = _clients.TryAdd(channel.ChannelId, freeSwitch);
                if (added)
                {
                    await freeSwitch.Connect();

                    bool ready = await freeSwitch.Resume() && await freeSwitch.MyEvents() && await freeSwitch.DivertEvents();

                    if (!ready)
                    {
                        await freeSwitch.Close();

                        return;
                    }
                }
                if (ClientReady != null)
                {
                    ClientReady(this, new InboundClientEventArgs(freeSwitch));
                }
            }
            catch (Exception) {
                if (channel != null)
                {
                    channel.Close();
                }
            }
        }
 private async void OnClientConnect(object sender, ClientConnectedEventArgs e) {
     ITcpChannel channel = e.Channel;
     FreeSwitch freeSwitch = new FreeSwitch(ref channel);
     try {
         var added = _clients.TryAdd(channel.ChannelId, freeSwitch);
         if (added) {
             await freeSwitch.Connect();
             bool ready = await freeSwitch.Resume() && await freeSwitch.MyEvents() && await freeSwitch.DivertEvents();
             if (!ready) {
                 await freeSwitch.Close();
                 return;
             }
         }
         if (ClientReady != null) ClientReady(this, new InboundClientEventArgs(freeSwitch));
     }
     catch (Exception) {
         if (channel != null) channel.Close();
     }
 }
Ejemplo n.º 3
0
 public InboundClientEventArgs(Inbound.FreeSwitch freeswitch)
 {
     _freeswitch = freeswitch;
 }
 public InboundClientEventArgs(Inbound.FreeSwitch freeswitch)
 {
     _freeswitch = freeswitch;
 }