Pub/ Sub

Nowadays many applications use real-time communication. To make it happen, you need to put servers somewhere to organize WebSocket communication. 

We, at Jexia, decided to eliminate this headache from you. Now you can use our Pub/Sub service and enjoy real-time communication between clients. Furthermore, in 1-click you can activate log storage for your channels and retrieve log when you need it. 

What do you need to have it?

1. You need to create channel(s) in our admin panel

2. Setup policy for the channel (Subscribe/Publish) 

3. Use our updated JavaScript SDK

import { jexiaClient, realTime } from "jexia-sdk-js";  
  
const rtm = realTime();  
 // Inititate Jexia Client 
jexiaClient().init({  
  projectID: "your-project-id",  
  key: "your-api-key",    
  secret: "your-api-secret"  
}, rtm);  

//Initiate a channel
const channel = rtm.channel("my_channel");

// Subscribe to listen messages
channel.subscribe(
  message => {
    console.log(message); // we've got a message from the channel
  },
  error => {
    console.log(error); // Subscription Error: (1001): resource "my_camel" is unavailable
  },
  () => { // complete
    // connection to the channel has been closed
  }
); 
// Send message to channel 
channel.publish({
  product: "apple",
  amount: 42
});  
// or
channel.publish("Some text string here...");  

// Get channel Log
channel
.getLog(field => field("sender_id").isEqualTo(user.id))  // Same filters as in DataSet
.subscribe(
  messages => {
    console.log(messages); 
  },
  error => {
    console.log(error); // Subscription Error: (2): none of the given actions ["read"] for this resource are allowed
  }

Limitation

There is only one limitation you have, maximum message size cannot be more than 64 kb.