1.2.1 • Published 3 years ago

nats-proxy-bk v1.2.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

nats-proxy-bk

npm

library to bridge websocket to nats-like usage for bahasakita projects.

Installation

NPM

npm install nats-proxy-bk

CDN

Normal, development, and minified versions of the bundle can obtained via UNPKG.

<script type="text/javascript" src="https://unpkg.com/nats-proxy-bk/dist/nats-proxy-bk.js"></script>

Development (includes eval sourcemaps):

<script type="text/javascript" src="https://unpkg.com/nats-proxy-bk/dist/nats-proxy-bk.dev.js"></script>

Minified (for production use):

<script type="text/javascript" src="https://unpkg.com/nats-proxy-bk/dist/nats-proxy-bk.min.js"></script>

Basic Usage

var NATSProxy = require('nats-proxy-bk');
var nats = new NATSProxy('ws://localhost:4223');

// With options
const options = {
  protocol: "nats",
  timeout: 10
}
var nats = new NATSProxy('ws://localhost:4223', options);

// Simple Publisher
nats.publish('foo', 'Hello World!');

// Simple Subscriber
nats.subscribe('foo', function(msg) {
  console.log('Received a message: ' + msg);
});

// Unsubscribing
nats.unsubscribe('foo');

// Request Streams
nats.request('request', 'Hello World!', function(response) {
  console.log('Got a response in msg stream: ' + response);
});

// Close connection
nats.close();

Secure Websockets

Connections can be made to secure websockets by using the wss protocol in the url passed to NATSProxy:

new NATSProxy('wss://localhost:4223');
1.2.0

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.10

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.0

3 years ago