1.0.4 • Published 6 years ago

actioncable-nodejs v1.0.4

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

actioncable-nodejs

ActionCable NodeJS client Implementation.

Getting Started

npm install actioncable-nodejs --save

const ActionCable = require('./actioncable/actioncable.js');

let cable_url = 'ws://localhost:3000/cable';

let cable = new ActionCable(cable_url, {
  // If you validate the origin on the server, you can set that here
  origin: 'http://localhost:3000',

  // Using headers with an API key for auth is recommended
  // because we dont have the normal browser session to authenticate with
  headers: {
    'X-Api-Key': 'someexampleheader'
  }
});

let subscription = cable.subscribe('RouterTestAgentChannel', {
  connected() {
    console.log("connected");
  },

  disconnected() {
    console.log("disconnected");
  },

  rejected() {
    console.log("rejected");
  },

  received(data) {
    console.log("received");
    console.log(data);
  }
});

// Send a message to the server
subscription.perform("command_processed", {foo: 'bar'});
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago