# message-subscription-websocket

> tuya message subscription websocket

Latest version **1.0.2** (published 2024-04-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install message-subscription-websocket
pnpm add message-subscription-websocket
yarn add message-subscription-websocket
bun add message-subscription-websocket
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-04-25 |
| First published | 2024-03-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 47.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | barbu_lucian_stefan |
| Keywords | tuya, message, subscription, websocket |

## Links

- npm: https://www.npmjs.com/package/message-subscription-websocket
- npm.io page: https://npm.io/package/message-subscription-websocket

## Dependencies (4)

- [ws](https://npm.io/package/ws.md) ^7.4.5
- [axios](https://npm.io/package/axios.md) ^1.6.8
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.0.0
- [@tuya/tuya-connector-nodejs](https://npm.io/package/@tuya/tuya-connector-nodejs.md) ^2.1.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-04-25
- 0.0.8-next.0 (next) — 2024-04-01
- 1.0.1 — 2024-04-10
- 1.0.0 — 2024-04-10
- 0.0.22 — 2024-04-02
- 0.0.21 — 2024-04-02
- 0.0.20 — 2024-04-01
- 0.0.19 — 2024-04-01
- 0.0.18 — 2024-04-01
- 0.0.17 — 2024-04-01
- 0.0.16 — 2024-04-01
- 0.0.15 — 2024-04-01
- 0.0.14 — 2024-04-01
- 0.0.11 — 2024-04-01
- 0.0.10 — 2024-04-01
- … 6 more at https://npm.io/package/message-subscription-websocket/versions

## README

# Connector to Tuya's Messaging Service using the Node.js SDK from Tuya

## Environment

+ Nodejs >= 12.0
+ yarn

## Start

1. Install
```bash
yarn
```

2. Build
```bash
yarn build
```

3. Publish
```bash
yarn deploy
```

## Run example

1. Install
```bash
yarn
```

2. Config your accessId and accessKey in `example/index.js`

```js
const client = new TuyaWebsocket({
  accessId: "your accessId",
  accessKey: "your accessKey",
  url: TuyaWebsocket.URL.CN,
  env: TuyaWebsocket.env.PROD,
  maxRetryTimes: 100,
});
```

3. Start
```bash
yarn example
```

## Example code

```js
import TuyaWebsocket from "xxx";

const client = new TuyaWebsocket({
  accessId: "your accessId",
  accessKey: "your accessKey",
  url: TuyaWebsocket.URL.CN,
  env: TuyaWebsocket.env.PROD,
  maxRetryTimes: 100,
});

client.open(() => {
  console.log('open');
});

client.message((ws, message) => {
  client.ackMessage(message.messageId);
  console.log('message', message);
});

client.reconnect(() => {
  console.log('reconnect');
});

client.ping(() => {
  console.log('ping');
});

client.pong(() => {
  console.log('pong');
});

client.close((ws, ...args) => {
  console.log('close', ...args);
});

client.error((ws, error) => {
  console.log('error', error);
});

client.start()

```

---
_Source: https://npm.io/package/message-subscription-websocket · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
