Skip to content
Andy edited this page Mar 18, 2018 · 34 revisions

Global response messages from backend

let resp = {
  id: 0123, // monotonic integer,
  type: 'INIT' | 'AUTH' | '{etc}',
  from: 'client' | 'server',
  status: 'database_not_responded' // error atom
}

WS connected

let req = {
  id: 5555, // monotonic integer
  type: 'INIT',
  from: 'client',
  session_id: undefined | '636ce6bd-07cb-4d66-84eb-f8e3102ae24a' // UUID-v4 from document.localStorage
}

let resp = {
  id: 5555, // same as req
  type: 'INIT',
  from: 'server',
  session_id: 'f8ffeaca-15ce-442c-9ad0-a859f1acd6c0', // already new UUID-v4 SID with updated expiration time
  expires_in: 172800, // 2 days in seconds, parameter for auto renew session ID via JS
  // PROPOSAL: full timestamp instead of timing in seconds for better coverage
  user_id: undefined | 12345 // provides integer ID if the user has been already logged in
}
// update document.localStorage session_id field
// update telegram auth button start parameter

Authorization

let req = '/start {session_id}'

let resp = {
  id: 8888 // monotonic integer
  type: 'AUTH',
  from: 'server',
  user_id: 12345
}

Receiving data

let req = {
  id: 4444, // monotonic integer
  type: 'GET',
  from: 'client',
  meta: any, // user field (optional)
  content_id: 'user_attr' // unique tag for the data type
}

let resp = {
  id: 4444, // same as req
  type: 'GET',
  from: 'server',
  meta: any, // same as req
  content_id: 'user_attr', // same as req
  data: {} // object
}

Getting async updates from backend

let resp = {
  id: 4444,
  type: 'UPDATE',
  from: 'server',
  meta: undefined,
  content_id: 'user_attr',
  data: {} // object
}

Clone this wiki locally