Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.39 KB

README.md

File metadata and controls

60 lines (46 loc) · 1.39 KB

JavaScript WebSocket Client for Sorare

@sorare/actioncable

WebSocket/ActionCable client for Sorare.

Getting Started

npm install @sorare/actioncable --save

const { ActionCable } = require('@sorare/actioncable');

const cable = new ActionCable({
  url: 'wss://ws.sorare.com/cable',
  headers: {
    // 'Authorization': `Bearer <YourJWTorOAuthToken>`,
    // 'APIKEY': '<YourOptionalAPIKey>'
  },
});

cable.subscribe('aCardWasUpdated { id }', {
  connected() {
    console.log('connected');
  },

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

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

  received(data) {
    console.log('received');
    console.log(data);
  },
});

License

@sorare/actioncable is MIT licensed. Credits to ZackMattor/actioncable-nodejs for the initial work.