Skip to content

Instantly share code, notes, and snippets.

@ang-st
Last active December 13, 2021 15:44
Show Gist options
  • Save ang-st/8794a20dca4cd0465bb0c9a0113413c8 to your computer and use it in GitHub Desktop.
Save ang-st/8794a20dca4cd0465bb0c9a0113413c8 to your computer and use it in GitHub Desktop.
/// SEE doc.zebitex.com for availble channels
const WebSocket = require('ws')
const ws = new WebSocket('wss://pusher-stage.zebitex.com/app/pusher_key?protocol=7&client=js&version=5.0.3&flash=false'); // ws.zebitex.com for prod
ws.on('open', function open() {
//// once connected : {"event":"pusher:connection_established","data":"{\"socket_id\":\"6.625468\",\"activity_timeout\":120}"}
const socket_id= "6.625468"
const info = await zebitex.command_rest.getSessionInfo()
//// info payload : {"sn":"ZEBXXXXXXXXTEX","isVerified":true,"isCorporate":false,"email":"user@domain.tld","lang":null,"nickname":"nick","canChangePassword":true,"isApplicationVerified":true,"emailNotifications":true,"pushNotifications":true,"productAnnouncementsNotifications":true,"mfa":{"enabled":false,"passed":false}}
const authtoken = await zebitex.command_rest.authWss( socket_id, info.sn);
/// authtoken payload : {"auth":"pusher_key:fffffffffffffffffffffffffffffd12ebb9139fb34fffffff"}
ws.send(JSON.stringify({"event":"pusher:subscribe","data":{"auth":"pusher_key:ffffffffffffffffffffffffffffffff7d12ebb9139fb34fffffff","channel":"private-ZEBXXXXXXXXTEX"}}))
})
ws.on('message', function incoming(data) {
console.log(data);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment