api-client-ts-azure-signalr
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@flipdish/api-client-typescript-azure-signalr

Typescript Flipdish SignalR client with Azure SignalR Support

Installation

npm install @flipdish/api-client-typescript-azure-signalr --save
yarn add @flipdish/api-client-typescript-azure-signalr
bower install @flipdish/api-client-typescript-azure-signalr --save

Usage

TypeScript

import * as FlipdishSignalR from '@flipdish/api-client-typescript-azure-signalr';
import { OrderCreatedEvent } from "@flipdish/api-client-typescript";

//You can also create configuration without passing anything, it will use default values
let configuration = new FlipdishSignalR.SignalRConfiguration(
  "API endpoint",
  "BEARER TOKEN, if not required pass `undefined`",
  "Logging, to enable pass `true`, to disable pass `false`"
);

//You should create the connection once per application
let connection = new FlipdishSignalR.SignalR(configuration);
//You can subscribe before starting connection
//connection.OrdersHub.OnOrderCreated(onOrderCreated);
//The callback will be called once the connection is started
connection.Start(onConnected);
//You can also subscribe after starting connection
connection.OrdersHub.OnOrderCreated(onOrderCreated);

function onConnected(){
    //Authenticating is a required step and can only be done AFTER the connection is started, hence why it is in this callback
    connection.AuthorizationHub.authenticate().then(onAuthenticated);
}

function onAuthenticated(auth: AuthorizationReply) {
    console.log(auth);
}

function onOrderCreated(order: OrderCreatedEvent) {
    console.log(order);
}

/api-client-ts-azure-signalr/

    Package Sidebar

    Install

    npm i api-client-ts-azure-signalr

    Weekly Downloads

    0

    Version

    1.0.2

    License

    UNLICENSED

    Unpacked Size

    378 kB

    Total Files

    10

    Last publish

    Collaborators

    • carly-crawford