Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[connection-status] Use Websockets #2222

Merged
merged 1 commit into from
Jun 28, 2018
Merged

[connection-status] Use Websockets #2222

merged 1 commit into from
Jun 28, 2018

Conversation

svenefftinge
Copy link
Contributor

Changed the connection status service to use websockets
and natural activity. (fixes #1490)

@kittaakos
Copy link
Contributor

I am doing the review now...

Please note, your connection-status tests have failed on the CIs.

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a few minor remarks. None of them are critical, they're rather cosmetic issues.


constructor(
@inject(ConnectionStatusOptions) @optional() protected readonly options: ConnectionStatusOptions = ConnectionStatusOptions.DEFAULT,
@inject(ILogger) protected readonly logger: ILogger
) {
this.statusChangeEmitter = new Emitter<ConnectionStatus>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please switch to property injection then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to use it without injection (see mock-connection-service.ts)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, then it makes sense. 👍


constructor(
@inject(WebSocketConnectionProvider) protected readonly wsConnectionProvider: WebSocketConnectionProvider,
@inject(PingService) protected readonly pingservice: PingService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pingservice -> pingService please.

this.fireStatusChange(newState);
}
// schedule offline
this.timer = this.setTimeout(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary async.


private scheduledPing: number | undefined;

constructor(
Copy link
Contributor

@kittaakos kittaakos Jun 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use property injection.

Edited: Obsolete. See: #2222 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above


/**
* Clients can listen on connection status change events.
*/
readonly onStatusChange: Event<ConnectionStatus>;
readonly onStatusChange: Event<ConnectionState>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be onStateChange.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, updateStatus and fireStatusChange should be renamed to updateState and fireStateChange due to the ConnectionStatus removal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed state to status

Changed the connection status service to use websockets
and natural activity. (fixes #1490)

Signed-off-by: svenefftinge <sven.efftinge@typefox.io>
@kittaakos
Copy link
Contributor

It works nicely. The tests are passing (locally) too. I have one more question; shouldn't we bind the PingService inSingletonScope?

@svenefftinge
Copy link
Contributor Author

shouldn't we bind the PingService inSingletonScope?

There is no reason, it will be created once as it is requested only once.
And even if there was another client it doesn't matter to have it twice, because it is stateless.

@kittaakos
Copy link
Contributor

client it doesn't matter to have it twice, because it is stateless.

Alright, let's leave as is.

@kittaakos kittaakos self-requested a review June 28, 2018 10:04
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works nicely. Thanks!

@svenefftinge svenefftinge merged commit 3fbd5e5 into master Jun 28, 2018
@svenefftinge svenefftinge deleted the GH-1490 branch June 28, 2018 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alive check is spamming network tab in the dev tools
2 participants