Feature: Website SDK (#653)

Add SDK functions

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-04-03 13:04:58 +05:30
committed by GitHub
parent 7fcd2d0e85
commit cb22b396eb
38 changed files with 734 additions and 262 deletions

View File

@@ -2,8 +2,8 @@ import { createConsumer } from '@rails/actioncable';
class BaseActionCableConnector {
constructor(app, pubsubToken) {
const consumer = createConsumer();
consumer.subscriptions.create(
this.consumer = createConsumer();
this.consumer.subscriptions.create(
{
channel: 'RoomChannel',
pubsub_token: pubsubToken,
@@ -16,6 +16,10 @@ class BaseActionCableConnector {
this.events = {};
}
disconnect() {
this.consumer.disconnect();
}
onReceived = ({ event, data } = {}) => {
if (this.events[event] && typeof this.events[event] === 'function') {
this.events[event](data);