2.9.0-snapshot.14 • Published 12 months ago

podasync-ws-only v2.9.0-snapshot.14

Weekly downloads
14
License
MIT
Repository
github
Last release
12 months ago

Synopsis

Fanap's POD Async service (DIRANA) - Websocket Only

Code Example

First you have to require PodAsync in your project.

var Async = require('podasync-ws-only');

To be able to connect to async server, you should set some parameters. Websocketsprotocol is currently supported.

Websocket protocol parameters

var params = {
  socketAddress: "ws://chat-sandbox.pod.land/ws",
  serverName: "chat-server",
  reconnectOnClose: true,
  connectionCheckTimeout: 10000,
  asyncLogging: {
    onFunction: true,
    onMessageReceive: true,
    onMessageSend: true
  }
};

After setting parameters you can make a new connection to Async server.

var asyncClient = new Async(params);

Async Ready Event

After making a new connection, you should wait for asyncReady event to fire so you could be sure that the connection has been estabilished and you are ready to go

asyncClient.on("asyncReady", function() {
  /**
  * Write your code inside asyncReady() function
  */
});

Receive messages

In order to receive messages from Async server, you could listen to message event.

/**
* Listening to responses came from DIRANA
*/
asyncClient.on("message", function(message, ack) {
  console.log(message);
});

Send message

To send a new message to Async server you can use send() function.

/**
* A Custom Message To be Send Through DIRANA
*/
var customMessage = {
  type: 3,
  content: {
    receivers: ["receiver1", "receiver2", "..."],
    content: "Hello Buddy!"
  }
};

/**
* Sending Message
*/
asyncClient.send(customMessage);

Motivation

This module helps you to easily connect POD chat service.

Installation

npm install podasync --save

API Reference

API Docs from POD

Tests

npm test

Contributors

You can send me your thoughts about making this repo great :) Email

License

Under MIT License.

2.9.0-snapshot.37

12 months ago

2.9.0-snapshot.5

2 years ago

2.9.0-snapshot.4

2 years ago

2.9.0-snapshot.7

2 years ago

2.9.0-snapshot.6

2 years ago

2.9.0-snapshot.9

2 years ago

2.9.0-snapshot.8

2 years ago

2.9.0-snapshot.3

2 years ago

2.8.1-snapshot.0

2 years ago

2.9.0-snapshot.1

2 years ago

2.9.0-snapshot.2

2 years ago

2.7.11

2 years ago

2.7.9-snapshot.0

3 years ago

2.7.9

4 years ago

2.7.8

4 years ago

2.7.7

4 years ago

2.7.5

6 years ago