Skip to content

Commit

Permalink
Fix AppConnectionState
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Jan 15, 2021
1 parent 5b19ab0 commit e509803
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.1.183
# Upcoming
### Client
* Feature: Auto Configure Windows Defender Firewall
* Update: Improve diagnosing
Expand Down
Binary file modified Pub/Version.json
Binary file not shown.
Binary file modified VpnHood.Client.App.Android/Assets/SPA.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion VpnHood.Client.App.UI.Html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vpnhood-spa",
"version": "1.0.73",
"version": "1.0.74",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client.App.UI.Html/src/components/ErrorSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
methods: {
diagnose() {
window.gtag('event', 'diagnose');
this.store.state.isDiagnosedStarted = true;
this.store.state.hasDiagnosedStarted = true;
const clientProfileId = this.store.state.lastActiveClientProfileId;
this.store.state.activeClientProfileId = clientProfileId;
this.store.invoke("diagnose", { clientProfileId });
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client.App.UI.Html/src/pages/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,21 @@ export default {
connect(item) {
window.gtag('event', 'connect');
this.store.state.isDiagnosedStarted = false;
this.store.state.hasDiagnosedStarted = false;
this.store.state.activeClientProfileId = item.clientProfile.clientProfileId;
this.store.invoke("connect", { clientProfileId: item.clientProfile.clientProfileId });
},
diagnose(item) {
window.gtag('event', 'diagnose');
this.store.state.isDiagnosedStarted = true;
this.store.state.hasDiagnosedStarted = true;
this.store.state.activeClientProfileId = item.clientProfile.clientProfileId;
this.store.invoke("diagnose", { clientProfileId: item.clientProfile.clientProfileId });
},
disconnect() {
window.gtag('event', 'disconnect');
this.store.state.clientState = this.$t("disconnecting");
this.store.state.connectionState = "Disconnecting";
this.store.invoke("disconnect");
},
Expand Down
Binary file modified VpnHood.Client.App.Win/Resources/SPA.zip
Binary file not shown.
29 changes: 17 additions & 12 deletions VpnHood.Client.App/VpnHoodApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,13 @@ public async Task Connect(Guid clientProfileId, bool diagnose = false, string us
}
catch (Exception ex)
{
VhLogger.Current?.LogError(ex.Message);
LastException = ex;
Disconnect();
//user may disconnect before connection closed
if (!_hasDisconnectedByUser)
{
VhLogger.Current?.LogError(ex.Message);
LastException = ex;
Disconnect();
}
throw;
}
finally
Expand Down Expand Up @@ -274,11 +278,8 @@ private void PacketCapture_OnStopped(object sender, EventArgs e)

public void Disconnect(bool byUser = false)
{
if (_client == null)
{
VhLogger.Current = CreateLogger(false);
if (_isDisconnecting)
return;
}

try
{
Expand All @@ -288,14 +289,17 @@ public void Disconnect(bool byUser = false)
_hasDisconnectedByUser = true;

// check for any success
if (_client.ReceivedByteCount > 1000)
_hasAnyDataArrived = true;
else if (LastException == null)
LastException = new Exception("No data has been arrived!");
if (_client != null)
{
if (_client.ReceivedByteCount > 1000)
_hasAnyDataArrived = true;
else if (LastException == null)
LastException = new Exception("No data has been arrived!");
}

// check diagnose
if (_hasDiagnoseStarted && LastException == null)
LastException = new Exception("Diagnose has been finished!");
LastException = new Exception("Diagnose has been finished and no issue has been detected.");

ActiveClientProfile = null;

Expand All @@ -315,6 +319,7 @@ public void Disconnect(bool byUser = false)
}
finally
{
_isConnecting = false;
_isDisconnecting = false;
}
}
Expand Down

0 comments on commit e509803

Please sign in to comment.