Ejemplo n.º 1
0
        private void EndCall(object o, EventArgs e)
        {
            Port port = (o as Port);
            Port secondPort;

            port.EndCallEventOnPort -= EndCall;
            var connection = ActiveConnections.FirstOrDefault(x => (x.Value == (o as Port).PhoneNumber) || (x.Key == (o as Port).PhoneNumber));

            if (port.PhoneNumber == connection.Key)
            {
                secondPort = Ports.First(x => x.PhoneNumber == connection.Value);
            }
            else
            {
                secondPort = Ports.First(x => x.PhoneNumber == connection.Key);
            }
            List <CallInfo> calls = Calls.FirstOrDefault(x => (x.Key.Key == port.PhoneNumber && x.Key.Value == secondPort.PhoneNumber) || (x.Key.Value == port.PhoneNumber && x.Key.Key == secondPort.PhoneNumber)).Value;
            CallInfo        call  = calls[calls.Count - 1];

            call.FinishCall(DateTime.Now);
            EndCallEvent?.Invoke(this, call);
            secondPort.EndCallEventOnPort -= EndCall;
            ActiveConnections.Remove(connection.Key);
        }