Skip to content

A ts HubSockets client to be used with the C# server-side HubSockets nuget package.

Notifications You must be signed in to change notification settings

sladewasinger/HubSockets-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A ts HubSockets client to be used with the C# server-side HubSockets nuget package.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages