# gohub

> JS Client for Go Hub WebSockets

Latest version **0.2.0** (published 2019-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install gohub
pnpm add gohub
yarn add gohub
bun add gohub
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2019-05-17 |
| First published | 2019-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nikko Miu |
| Maintainers | nikkoamiu |
| Keywords | websocket, golang, client |

## Links

- npm: https://www.npmjs.com/package/gohub
- Repository: https://gitlab.com/go-nm/hub
- Homepage: https://gitlab.com/go-nm/hub#readme
- Issues: https://gitlab.com/go-nm/hub/issues
- npm.io page: https://npm.io/package/gohub

## 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

- 0.2.0 (latest) — 2019-05-17
- 0.1.1 — 2019-05-12
- 0.1.0 — 2019-05-12

## README

# Go Hub (JS Client)

This is the client library for [Go Hub](https://gitlab.com/go-nm/hub). It aims to simplify the use of the topic and room concepts that exist in the Go Hub library.

## Basic Usage

This library is compatible with both Common JS and ES6 modules. The examples shown here are using the Common
JS library version. However, they can easily be changed to work with ES6 modules.

```js
let sock = new Socket('ws://localhost:3000/ws');

// When the channel is opened join rooms (this will be called with reconnects too)
sock.onOpen(e => {
  // Connect to the channel
  const channel = sock.join('chatroom:334');

  // On event 'message_received' from the server log the event and data
  channel.onEvent('message_received', (event, payload) => {
    console.log(event, payload);
  });

  // Send a message to the server
  channel.send('send_message', 'sweet');

  // Leave the channel
  channel.leave();
});

// Connect to the WebSocket
sock.connect();
```

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