0.2.29 • Published 2 years ago

@turnly/realtime-client v0.2.29

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

RTM Client

A socket.io-client wrapper to facilitate connecting to our RTM & Streaming API.

Installation

pnpm add @turnly/realtime-client

Streaming API

import { Realtime } from '@turnly/realtime-client'

const stream = new Realtime.Stream({ url: 'https://{organization}.turnly.app' })

/**
 * Sets your secret token.
 */
stream.setAuthToken(process.env.TURNLY_STREAM_API_TOKEN) // '<your-token>'

/**
 * Subscribes to single event.
 */
stream.subscribe('ticket.announced', event => console.log(event))

/**
 * Unsubscribes
 */
const unsub = stream.subscribe('ticket.discarded', event => console.log(event))

/**
 * Closes the subscription.
 */
unsub()

/**
 * Subscribes to multiple events.
 */
stream.subscribe(['ticket.created', 'customer.created'], event => console.log(event))

/**
 * Subscribes to all events.
 */
stream.subscribe(event => console.log(event))

Platform Realtime API

import { Realtime } from '@turnly/realtime-client'

const rtm = new Realtime.Platform({
  url: 'https://{organization}.turnly.app',
  channel: 'helpdesk',
})

/**
 * Subscribes to single event.
 */
rtm.subscribe('service.tickets.ahead', event => console.log(event))

Realtime API

import { Realtime } from '@turnly/realtime-client'

const rtm = new Realtime.Widgets({
  url: 'https://{organization}.turnly.app',
  channel: 'queuing',
})

/**
 * Subscribes to single event.
 */
rtm.subscribe('service.tickets.ahead', event => console.log(event))

Event Response

The event from the subscription will contain following properties:

NameTypeDescription
idStringUnique identifier for this event.
nameStringA human-readable name for the event.
typeStringThe operation of the event, commonly update or create.
payloadObjectContains data related to the event.
timestampnumberThe UNIX timestamp from the server.
0.1.74

2 years ago

0.2.1

2 years ago

0.2.29

2 years ago

0.2.17

2 years ago

0.2.26

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.1.19

2 years ago

0.1.15

2 years ago

0.1.8

2 years ago