Class: Channel

Channel


new Channel()

OO wrapper around channels endpoint.
Channel has two special methods called publish and poll. First one will send message to the channel and second one will create long polling connection which will listen for messages.

Properties:
Name Type Argument Default Description
name String
instanceName String
type String
group Number <optional>
null
group_permissions String <optional>
null
other_permissions String <optional>
null
custom_publish Boolean <optional>
null
Source:
Example
Channel.please().get('instance-name', 'channel-name').then((channel) => {
  return channel.publish({x: 1});
});

Channel.please().get('instance-name', 'channel-name').then((channel) => {
  const poll = channel.poll();

  poll.on('start', function() {
    console.log('poll::start');
  });

  poll.on('stop', function() {
    console.log('poll::stop');
  });

  poll.on('message', function(message) {
    console.log('poll::message', message);
  });

  poll.on('custom', function(message) {
    console.log('poll::custom', message);
  });

  poll.on('create', function(data) {
    console.log('poll::create', data);
  });

  poll.on('delete', function(data) {
    console.log('poll::delete', data);
  });

  poll.on('update', function(data) {
    console.log('poll::update', data);
  });

  poll.on('error', function(error) {
    console.log('poll::error', error);
  });

  poll.start();
});