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); }
//Methods-handlers of Port events protected virtual void PortOnPortEnabled(object sender, EventArgs e) { var port = sender as Port; if (DisabledPorts.Contains(port)) { DisabledPorts.Remove(port); EnabledPorts.Add(port); } else if (ActivePorts.ContainsKey(port)) { ActivePorts.Remove(port); EnabledPorts.Add(port); } }