hubsockets-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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', '');

Package Sidebar

Install

npm i hubsockets-client

Weekly Downloads

5

Version

1.0.4

License

ISC

Unpacked Size

8.55 kB

Total Files

6

Last publish

Collaborators

  • austinwasinger