# @mangar2/mqttversion

> implements interface adapter version

Latest version **1.2.2** (published 2020-12-10) · LGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @mangar2/mqttversion
pnpm add @mangar2/mqttversion
yarn add @mangar2/mqttversion
bun add @mangar2/mqttversion
```

## 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.2.2 |
| Published | 2020-12-10 |
| First published | 2019-10-27 |
| Weekly downloads | 0 |
| License | LGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Volker Böhm |
| Maintainers | mangar2 |
| Keywords | mqtt |

## Links

- npm: https://www.npmjs.com/package/@mangar2/mqttversion
- Repository: https://github.com/Mangar2/yaha/tree/master/node_modules/@mangar2/mqttversion
- Homepage: https://github.com/Mangar2/yaha.git
- npm.io page: https://npm.io/package/@mangar2/mqttversion

## Recent versions

- 1.2.2 (latest) — 2020-12-10
- 1.2.1 — 2020-03-01
- 1.2.0 — 2020-01-14
- 1.1.0 — 2019-10-27

## README

<!-- This file is generated by jsmddoc version 0.1 -->

# Abstract

## Contents

- [Meta](#Meta)
- [Global Functions](#Global-functions)
  - [connect](#connect)
  - [disconnect](#disconnect)
  - [onConnect](#onConnect)
  - [onDisconnect](#onDisconnect)
  - [onPublish](#onPublish)
  - [onPubrel](#onPubrel)
  - [onSubscribe](#onSubscribe)
  - [onUnsubscribe](#onUnsubscribe)
  - [publish](#publish)
  - [pubrel](#pubrel)
  - [subscribe](#subscribe)
  - [unsubscribe](#unsubscribe)

## Meta

## Global functions

### connect

`connect (version, options) => {Object}`

Creates the objects to connect ot a broker

#### connect Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `version` | `string` | interface version '1 . 0' or '0 . 0' | |
| `options` | `Object` | connect options | |

#### options properties

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `clientId` | `string` | unique client identifier | |
| `host` | `string` | host name of the client host | |
| `port` | `number` | port number of the clien listening port | |
| `clean` | `bool` | true , if the connection is cleaned up after disconnect | |
| `keepAlive` | `nubmer` | keep alive time in milliseconds | |

#### connect returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

### disconnect

`disconnect (clientId) => {Object}`

Creates the objects to disconnect from a broker

#### disconnect Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `clientId` | `string` | unique client identifier | |

#### disconnect returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

### onConnect

`onConnect (headers, payload) => {Object}`

Creates the return types for a connect request

#### onConnect Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | message headers | |
| `payload` | `Object` | payload to return | |

#### onConnect returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode } |

### onDisconnect

`onDisconnect (headers) => {Object}`

creates the return types for a disconnect request

#### onDisconnect Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | message headers | |

#### onDisconnect returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode } |

### onPublish

`onPublish (headers) => {Object}`

creates the return types for a receive message

#### onPublish Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | input headers | |

#### onPublish returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode , packetid } |

### onPubrel

`onPubrel (headers) => {Object}`

Creates the objects for a qos = 2 commit message "pubcomp"

#### onPubrel Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | pubrel message headers | |

#### onPubrel returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode , packetid } |

### onSubscribe

`onSubscribe (headers, qosArray) => {Object}`

Creates the subscribe result objects

#### onSubscribe Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | input headers | |
| `qosArray` | `Array` | quality of service reply array | |

#### onSubscribe returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode , packetid } |

### onUnsubscribe

`onUnsubscribe (headers) => {Object}`

creates the return types for a disconnect request

#### onUnsubscribe Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `headers` | `Object` | message headers | |

#### onUnsubscribe returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , statusCode , packetid } |

### publish

`publish (version, token, message, qos, dup, retain, packetid) => {Object}`

Creates the objects to publish to a client

#### publish Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `version` | `string` | interface version ( '0 . 0' or '1 . 0' ) | |
| `token` | `string` | connection token | |
| `message` | `Object` | payload | |
| `qos` | `number` | quality of service ( 0 , 1 , 2 ) | |
| `dup` | `number` | duplicate flag 1 ( true ) or 0 ( false ) . Identifies duplicate packages | |
| `retain` | `number` | flag 1 ( true ) or 0 ( false ) . Requrests to retain the message | |
| `packetid` | `number` | unique id of the package | |

#### publish returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

### pubrel

`pubrel (version, token, packetid) => {Object}`

creates the return types for a receive pubrel message

#### pubrel Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `version` | `string` | interface version ( '0 . 0' or '1 . 0' ) | |
| `token` | `string` | connection token | |
| `packetid` | `number` | of the packet ( must be the same id as send by publish ! ) | |

#### pubrel returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

### subscribe

`subscribe (version, topics, clientId, packetid) => {Object}`

Subscribes to a client

#### subscribe Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `version` | `string` | interface version ( '0 . 0' or '1 . 0' ) | |
| `topics` | `Object` | { topic : qos , . . . } | |
| `clientId` | `string` | unique client identifier | |
| `packetid` | `number, undefined` | unique id of the package ( not used on version 0 . 0 ) | |

#### subscribe returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

### unsubscribe

`unsubscribe (version, topics, clientId, packetid) => {Object}`

Creats the objects to unsubscribe from a client

#### unsubscribe Parameters

| Name | Type | Description |
| ---------- | ------------ | ----------------- |
| `version` | `string` | interface version ( '0 . 0' or '1 . 0' ) | |
| `topics` | `Array` | array of topic strings | |
| `clientId` | `string` | unique client identifier | |
| `packetid` | `number, undefined` | unique id of the package ( not used on version 0 . 0 ) | |

#### unsubscribe returns

| Type | Description |
| ---- | ----------- |
| `Object` | { headers , payload , resultCheck ( result ) } |

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