1.0.4 • Published 2 years ago

hubsockets-client v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago