Skip to content

Commit

Permalink
improved connection handling (#656)
Browse files Browse the repository at this point in the history
- improved cleanup on disconnect
  - fixed user follow failing after token refresh
  - set default RetryConnectionInterval to 0 to avoid issues after disconnects
  • Loading branch information
sei-aschlackman authored Apr 25, 2024
1 parent dc7c0ed commit a98fb2f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/app/components/wmks/wmks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,16 @@ export class WmksComponent implements OnInit, OnDestroy {
if (this.connectTimerSubscription != null) {
this.connectTimerSubscription.unsubscribe();
}

this.vmService.disconnect();
}

private setVmId(value: string) {
if (this.connectTimerSubscription != null) {
this.connectTimerSubscription.unsubscribe();
}

// destroy and re-create the wmksContainer
this.showWmks = false;
this.showWmks = true;

this._vmId = value;

this.vmService.disconnect();
}

Expand Down
8 changes: 8 additions & 0 deletions src/app/services/signalr/signalr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class SignalRService {

private userId: string;
private viewId: string;
private activeVmId: string;

private apiUrl: string;

Expand Down Expand Up @@ -78,10 +79,15 @@ export class SignalRService {
if (this.userId && this.viewId) {
this.joinUser(this.userId, this.viewId);
}

if (this.activeVmId) {
this.setActiveVirtualMachine(this.activeVmId);
}
}

public joinUser(userId: string, viewId: string) {
this.userId = userId;
this.viewId = viewId;

this.startConnection().then(() => {
this.hubConnection.invoke('JoinUser', userId, viewId).then((vmUser) => {
Expand All @@ -100,12 +106,14 @@ export class SignalRService {
}

public setActiveVirtualMachine(vmId: string) {
this.activeVmId = vmId;
this.startConnection().then(() => {
this.hubConnection.invoke('SetActiveVirtualMachine', vmId);
});
}

public unsetActiveVirtualMachine() {
this.activeVmId = null;
this.startConnection().then(() => {
this.hubConnection.invoke('UnsetActiveVirtualMachine');
});
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/vsphere/vsphere.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ export class VsphereService {

public disconnect() {
if (this.wmks != null) {
this.wmks.destroy();
this.wmks.unregister();
// this.wmks.disconnect();
this.wmks.disconnect();
this.wmks.destroy();
this.wmks = null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/assets/config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
{ "name": "Slowest", "value": 500 }
],
"WMKS": {
"RetryConnectionInterval": 5000
"RetryConnectionInterval": 0
}
}

0 comments on commit a98fb2f

Please sign in to comment.