1.0.0 • Published 2 years ago

@auxilium/socket-client v1.0.0

Weekly downloads
17
License
ISC
Repository
gitlab
Last release
2 years ago

Socket Client

Client library for communicating with Datalynk's Socket Server.

Setup

Prerequisites

Instructions

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

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..
1.0.0

2 years ago

0.0.16

3 years ago

0.0.15

5 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago