Ejemplo n.º 1
0
        protected virtual void PortOnPortEndCall(object sender, CallEventArgs e)
        {
            var call = CurrentCalls.FirstOrDefault(x => x.RecieverNumber == e.number || x.SenderNumber == e.number);

            if (call == null)
            {
                return;
            }

            var port1 = CallingPorts.FirstOrDefault(x => x.Number == call.SenderNumber);

            if (port1 == null)
            {
                return;
            }

            var port2 = CallingPorts.FirstOrDefault(x => x.Number == call.RecieverNumber);

            if (port2 == null)
            {
                return;
            }
            call.Finish();
            ServerFinishedCall?.Invoke(this, new ConnectionEventArgs(port1, port2, string.Format($"Call finished. Duration: {call.Duration:hh\\:mm\\:ss}")));
            CallingPorts.Remove(port1);
            CallingPorts.Remove(port2);
            EnabledPorts.Add(port1);
            EnabledPorts.Add(port2);

            CurrentCalls.Remove(call);
            StorageCalls.Add(call);
            CallFinished?.Invoke(call, EventArgs.Empty);
        }
Ejemplo n.º 2
0
        protected virtual void PortOnPortStateSetToActive(object sender, CallEventArgs phoneNumberArgs)
        {
            var port = sender as Port;

            if (DisabledPorts.Contains(port))
            {
                DisabledPorts.Remove(port);
                ActivePorts.Add(port, phoneNumberArgs.number);
            }
            if (EnabledPorts.Contains(port))
            {
                EnabledPorts.Remove(port);
                ActivePorts.Add(port, phoneNumberArgs.number);
            }
            CheckActivePortCalledNumber(port, phoneNumberArgs.number);
        }
Ejemplo n.º 3
0
 protected virtual void TerminalOnCallIsEnd(object sender, CallEventArgs e)
 {
     PortEndCall?.Invoke(this, new CallEventArgs(e.number));
 }
Ejemplo n.º 4
0
 protected virtual void TerminalOnBeginCall(object sender, CallEventArgs e)
 {
     State = PortState.Active;
     PortStateSetToActive?.Invoke(this, e);
 }