@auxilium/socket-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Socket Client

Client library for communicating with Datalynk's Socket Server.

Setup

Production

Prerequisites

Instructions

  1. Install library: npm install --save @auxilium/socket-client

Development

Prerequisites

Instructions

  1. Install dependencies: npm install
  2. Build or watch library: npm run [build|watch]
  3. Create an npm link: npm link
  4. Install library to client for testing: npm link @auxilium/client-socket

Quick Start

Minimal

import { AuxiliumSocketClient } from '@auxilium/socket-client';

const socket = new AuxiliumSocketClient('Optional URL Override, defaults to production');

Angular Wrapper

import { Injectable } from '@angular/core';
import { AuxiliumSocketClient} from '@auxilium/socket-client';

@Injectable({
	providedIn: 'root'
})
export class SocketService extends AuxiliumSocketClient {
    constructor() {
		super('Optional URL Override, defaults to production');
    }
}

const socket = new SocketService();

Examples

// call this if your token changes
socket.resume("1uf0dfbhr1g2efdoihqdubovsq", "sandbox");

// listen to records changing...
socket.onRecordChanges(52116, "sandbox")
	.subscribe(
		(changes: SliceRecordChanges) => {
			console.log('heard changes', changes);
		})

// listens to comment changes on a slice
socket.onCommentChanges(slice: number, spoke = this.defaultSpokeName);

// listens to changes on the slice itself (note, still janky)
socket.onSliceChanges(slice: number, spoke = this.defaultSpokeName);

Notes

  • socketId is a readonly property that is set when a connection to the server is established. if you attach this to your api call request object req.socket = socket.socketId, it will be the originator in the response calls
  • where arguments accept spokes, if not provided, they will default to the one set in the defaultSpoke... so... if you're only doing shit on one spoke, set it..

/@auxilium/socket-client/

    Package Sidebar

    Install

    npm i @auxilium/socket-client

    Weekly Downloads

    10

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    821 kB

    Total Files

    18

    Last publish

    Collaborators

    • auxilium