private void FSD_NetworkDisconnected(object sender, NetworkEventArgs e) { mPositionUpdateTimer.Stop(); DisconnectInfo disconnectInfo = new DisconnectInfo { Type = (mForcedDisconnect ? DisconnectType.Forcible : (mIntentialDisconnect ? DisconnectType.Intentional : DisconnectType.Other)), Reason = (mForcedDisconnect ? mKillReason : string.Empty) }; NetworkDisconnected?.Invoke(this, new NetworkDisconnectedEventArgs(disconnectInfo)); mIntentialDisconnect = false; mForcedDisconnect = false; mIsIdenting = false; mIsIdentPressed = false; if (disconnectInfo.Type == DisconnectType.Forcible) { if (!string.IsNullOrEmpty(disconnectInfo.Reason)) { NotificationPosted?.Invoke(this, new NotificationPostedEventArgs(NotificationType.Warning, $"Forcibly disconnected from the network: { disconnectInfo.Reason }")); } else { NotificationPosted?.Invoke(this, new NotificationPostedEventArgs(NotificationType.Warning, "Forcibly disconnected from the network.")); } PlaySoundRequested?.Invoke(this, new PlaySoundEventArgs(SoundEvent.Error)); } else { NotificationPosted?.Invoke(this, new NotificationPostedEventArgs(NotificationType.Info, "Disconnected from the network.")); } }
public void Disconnect(DisconnectInfo info) { NetworkDisconnected?.Invoke(this, new NetworkDisconnectedEventArgs(info)); if (FSD.Connected) { FSD.SendPDU(new PDUDeletePilot(OurCallsign, mConfig.VatsimId.Trim())); FSD.Disconnect(); } }
public void ForceDisconnect(string reason = "") { if (IsConnected) { FSD.SendPDU(new PDUDeletePilot(OurCallsign, mConfig.VatsimId.Trim())); FSD.Disconnect(); } DisconnectInfo disconnectInfo = new DisconnectInfo { Type = DisconnectType.Quiet, Reason = reason }; NetworkDisconnected?.Invoke(this, new NetworkDisconnectedEventArgs(disconnectInfo)); NotificationPosted?.Invoke(this, new NotificationPostedEventArgs(NotificationType.Warning, disconnectInfo.Reason)); }