https://github.com/smartsupp/smartsupp-sdk-websocket
https://github.com/smartsupp/smartsupp-sdk-websocket
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/smartsupp/smartsupp-sdk-websocket
- Owner: smartsupp
- Created: 2020-06-01T13:40:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-09T20:02:35.000Z (over 4 years ago)
- Last Synced: 2025-08-09T16:30:12.379Z (11 months ago)
- Language: TypeScript
- Size: 210 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Official Smartsupp websocket SDK for JavaScript
## Installation
```bash
npm install --save smartsupp-websocket
yarn add smartsupp-websocket
```
- We use [socket.io](https://github.com/socketio/socket.io-client) as websocket engine.
- Documentation can be found on the [Gihub Pages](https://smartsupp.github.io/smartsupp-sdk-websocket/).
## Usage
Create and initialize websocket client and connect to the server.
```js
import { createVisitorClient } from 'smartsupp-websocket'
const client = createVisitorClient({
data: {
id: null, // null or id returned from server
key: '__SMARTSUPP_ACCOUNT_KEY__',
// ...
},
})
// connect to server
client.connect().then((data) => {
console.log(data)
})
// received events
client.on('chat.message_received', (message) => {
console.log(message)
})
```
## Custom Promise Library
Customize promise library:
```js
import * as smartsuppWebsocket from 'smartsupp-websocket'
smartsuppWebsocket.setPromiseLibrary(Promise)
```
## Development
VuePress docs hot reload workaround:
```bash
make init NPMRC_FILE=~/.npmrc
npx npm-force-resolutions
npm install
```