Client library to communicate with Datalynk's socket server
npm install @auxilium/socket-clientnpm install --save @auxilium/socket-client
npm install
npm run [build|watch]
npm link
npm link @auxilium/client-socket
typescript
import { AuxiliumSocketClient } from '@auxilium/socket-client';
const socket = new AuxiliumSocketClient('Optional URL Override, defaults to production');
`
$3
`typescript
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();
``
$3
`typescript
// 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..