Skip to contentpackage
tws-tcm
v1.0.2Node.js SDK of TWS (Teambition Web Service) cloud messaging service.
node >=85 depscjstypesopen source
- license
- MIT
- deps
- 5
- unpacked
- 20.8 kB
- files
- 12
- node
- >=8
$npm install tws-tcm@1.0.2 README
GitHub-flavored package documentation.
downloads
Across all versions.
Download trend unavailable.
compatibility
Runtime metadata.
versions
Latest published Nov 13, 2019
maintainers
Registry package owners.
contents
Node.js SDK of TWS (Teambition Web Service) cloud messaging service.

Installation
Usage
'use strict'
const { TCMClient } = require('tws-tcm')
;(async function () {
const client = new TCMClient({
host: process.env.TCM_HOST,
appId: process.env.APP_ID,
appSecrets: [process.env.APP_SECRET]
})
// HTTP
await client.subscribe('some_topic', 'some_session_id')
await client.send([{
to: 'some_topic',
collapse_key: 'collapse_key',
time_to_live: 60,
data: 'data1'
}, {
to: 'some_topic',
Documentation
const { TCMClient } = require('tws-tcm')
new Client({ appId, appSecret[, host, timeout, cacheStore, rootCert, privateKey, certChain] })
- appId
String : The ID of your TWS application.
- appSecrets:
[]String : The secret passwords of your TWS application.
- host
String : Host URL of TCM service.
- timeout
Number : Optional, requst timeout in milliseconds, by default is 3000.
- rootCert
Buffer : Optional, the client root certificate.
- privateKey
Buffer : Optional, the client certificate private key.
- certChain
Buffer : Optional, the client certificate cert chain.
- maxSockets
Number : Optional, the client sockets.
- time
Boolean : Optional, enable timing for request.
- retryDelay
Number : Optional, delay time for retry, default to 200 ms.
- maxAttempts
Number : Optional, max attempts for a request, default to 3 times.
- retryErrorCodes
[]String : Optional, error codes that should retry, default to ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED', 'EHOSTUNREACH', 'EPIPE', 'EAI_AGAIN'].
TCMClient API
/**
* Client for TWS (Teambition Web Service) cloud messaging service..
*/
export declare class TCMClient {
private _client;
constructor(options: TCMOptions);
/**
* subscribe a topic with given sessionId.
* @param topic message topic.
* @param sessionId user session ID.
*/
subscribe(topic: string, sessionId: string): Promise<void>;
/**
* unsubscribe a topic with given sessionId.
* @param topic message topic.
* @param sessionId user session ID.
License
tws-tcm is licensed under the MIT license.
Copyright © 2017-2019 Teambition.
install size
Estimated unpacked size across 60 packages.
33.9 MB
Includes dependencies.
dependencies
6 direct · 3 outdated
collapse_key: 'collapse_key',
time_to_live: 60,
data: 'data2'
}])
})(console.error)
*/
unsubscribe(topic: string, sessionId: string): Promise<void>;
/**
* send one or more messages.
* @param body message array.
*/
send(body: Message[]): Promise<void>;
/**
* get online info for given user.
* @param userId user ID.
*/
getUserClients(userId: string): Promise<UserClients>;
/**
* get a TCM token for given user.
* @param userId user ID.
* @param source client label.
*/
sign(userId: string, source: string): Promise<Token>;
/**
* Just heart beat.
*/
heartBeat(): Promise<HeartBeat>;
}