Skip to content

Data Scoping and World Topics

Compare
Choose a tag to compare
@narenranjit narenranjit released this 10 Jul 17:26
· 268 commits to master since this release

Features

Epicenter Channel Manager (F.manager.ChannelManager)

getWorldChannel: World Channel allows you to choose topics to subscribe to

You can now subscribe for specific "topics" on the World Channel. For e.g.

const cm = new F.manager.ChannelManager();
const worldChannel = cm.getWorldChannel();
cm.subscribe(worldChannel.TOPICS.RUN, (data, meta)=> {
    //Gets all operations/variables/run reset notifications
});

The list of available topics are:

Topic Description
ALL All events
RUN All Run events
RUN_VARIABLES Variable sets only
RUN_OPERATIONS Operation executions only
RUN_RESET New run attached to the world
PRESENCE All Presence events
PRESENCE_ONLINE Online notifications only
PRESENCE_OFFLINE Offline notifications only
ROLES All role events
ROLES_ASSIGN Role assignments only
ROLES_UNASSIGN Role unassignments
getWorldChannel: Subscribing to the PRESENCE topic bootstraps info

Earlier the presence channel used to notify you of presence changes but you still needed to 'bootstrap' initial data for your current users in advance. Now the channel automatically queries for the status of the current users in the world and send it over. For e.g.

Example: Your world has users A,B, and C, out of who A&B are currently online.

const worldChannel = cm.getWorldChannel();
cm.subscribe(worldChannel.TOPICS.PRESENCE, (data, meta)=> {
    //Will be called once for A, and once for B, as well as once for every future change to status of A,B, or C
});

Data API Scoping

const DataService = F.service.Data;    
const groupScopeDataService = new DataService({    
    root: 'some-name', 
    scope: DataService.SCOPES.GROUP,   
});    
const userScopeDataService = new DataService({     
    root: 'some-name', 
    scope: DataService.SCOPES.USER,    
});    

Available scopes are:

Scope Readable By Writable By
GROUP Facilitators & Users in that group Faciliators in that group
USER Faciliator in that group. User who created the collection Faciliator in that group. User who created the collection
FACILITATOR Faciliators in that group Faciliators in that group
PROJECT Any user in the project Any user in the project
CUSTOM (default, to opt out of naming conventions) customize with Epicenter-api-proxy customize with Epicenter-api-proxy

Presence API: New method getStatusForUsers

This is similar to getStatus, except it takes in a whitelist of users to get presence for.

var pr = new F.service.Presence();
pr.getStatusForUsers([{ userId: 'a', userId: 'b'}]).then(function(onlineUsers) {
     console.log(onlineUsers[a].isOnline);
});

PasswordService

The new password service allows you to reset user passwords.

var ps = new F.service.Password();
ps.resetPassword('[email protected]', {
    subject: 'Please reset your password'
});

Misc

  • Promise rejection error message formats have been normalized to always have a type and message where possible.
  • Added normalizeSlashes utils to remove invalid slashes in url strings

Bug Fixes:

  • Ajax Transport: Fixed bug which prepended username to url when logging in over http