hubsockets-client
v1.0.4
Published
To be used with the HubSockets C# nuget package
Downloads
3
Maintainers
Readme
HubSockets-Client
A TypeScript HubSockets npm package to be used with the C# server-side HubSockets nuget package.
Repo: https://github.com/sladewasinger/HubSockets-Client
Server
https://github.com/sladewasinger/HubSockets
Usage:
Connecting:
import { HubSocketService } from 'hubsockets-client';
hubSocketService = new HubSocketService();
await hubSocketService.doConnect(
'wss://' + window.location.hostname + ':443/ws'
);
Listen for Events:
hubSocketService
.listenOn<GameState>('GameStateUpdated')
.subscribe((x) => this.gameStateUpdated(x));
Send with response as promise:
const hubResponse = await this.hubSocketService
.sendWithPromise<HubResponse<number>>('GetTotalPlayerCount', {});
const count = hubResponse.data;
Send without expecting a response:
hubSocketService.send('Clear', '');