private void OnPortStateChanged(object sender, StateEventArgs args) { if (!(sender is Port port)) { return; } var senderPort = SelectPort(port.PhoneNumber); if (senderPort == null) { Logger.Warn($"This number {port.PhoneNumber} is not in service."); return; } var receiverPort = args.PhoneNumber != 0 ? SelectPort(args.PhoneNumber) : GetConnectionSender(senderPort); if (receiverPort == null) { Logger.Warn($"This number {args.PhoneNumber} is not in service."); return; } ManageConnection(senderPort, receiverPort, args.IsPickedUpPhone, args.PhoneNumber == 0); }
public void OnTerminalStateChanged(object sender, StateEventArgs args) { if (!(sender is Terminal) || args == null) { return; } // разница состояний порта - до события и после // поднята трубка = Connected(1) -> Call(2) = 2-1 = 1 > 0 // положена трубка = Call(2) -> Connected(1) = 1-2 = -1 < 0 var arg = new StateEventArgs(args.State, args.PhoneNumber, (args.State - State) > 0); State = args.State; if (PortStateChanged != null) { PortStateChanged(this, arg); } }