-
Notifications
You must be signed in to change notification settings - Fork 35
Sync & Bani Controller Documentation
Sangat Sync and Bani controller are ways with which Sttm Desktop and Sttm Web can control each other. This is done through a special Sangat Sync API that can be used by any other app. Once the connection is established successfully desktop can control web (or other hosts) and vice versa
Sync API URL: https://api.sikhitothemax.org
Socket Source: ${SYNC_API_URL}/socket.io/socket.io.js
When talking about Sangat Sync, we will talk about two kinds of hosts
- Primary host / Desktop - The primary host is the one that generates namespace string and pin code so that all other secondary hosts can connect to it. In our case it's desktop, that's the primary host.
- Secondary host - which could be web, sunder-gutka, iGurbani, or any other app.
There is only one event that we emit and listen to. This event is called data
. Refer SikhiToTheMax API for more details on that. For this documentation, all we need to know is that all our socket emit
s and on
s will be using the event name as 'data'.
First of all desktop requests API to generate a 6-word random alphabetic string. This string is called the namespace string. The API request looks like this
const result = await request(`${SYNC_API_URL}/sync/begin/${host}`);
After getting namespace string from API, a 4 digit numeric pin is generated on the desktop.
This step needs to be done only on the Desktop. If you are trying to merely connect a secondary host with Desktop, you don't need to perform this step.
After pin and namespace string is generated on desktop, the
The secondary host sends a request-control
to the primary host. The format for that is
`URL: ${SYNC_API_URL}/${namesapceString}
{
host: 'sttm-web' | 'sunder-gutka'
type: 'request-control'
pin: 1234
}
{
host: 'sttm-desktop'
type: 'response-control'
success: true | false
}
When you send a Shabad to desktop, the following will be the format of the data sent that desktop can use with BaniDB API to fetch the required data.
{
type: 'shabad' // Other options: 'ceremony' | 'bani',
host: 'sttm-web',
pin: 1234,
shabadId: 12, /* Other options: instead of shabad Id use key ceremonyID for ceremonies and baniId for bani */
verseId: 1234,
gurmukhi: 'gurmukhi token of the shabad' // (needed for history store on desktop)
}
When you receive a Shabad from desktop, the following will be the format of the data received that you can use with BaniDB API to fetch the required data.
{
type: 'shabad',
host: 'sttm-desktop',
id: 12,
highlight: 1234,
homeId: 1234,
}
When you receive a Shabad from desktop, the following will be the format of the data received that you can use with BaniDB API to fetch the required data.
{
type: 'shabad',
host: 'sttm-desktop',
id: 12,
highlight: 1234,
verseChange: true,
}
{
host: 'sttm-desktop',
type: 'bani',
id: 1,
highlight: 2345,
baniLength: 'extra-long', // or long | medium | short
mangalPosition: 'above', // or below
verseChange: false,
}
{
host: 'sttm-desktop',
type: 'ceremony',
id: ceremonyID,
highlight: 2345,
verseChange: false,
}