@@ -5,7 +5,7 @@ const connection = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${a
55
66const api = new DerivAPIBasic ( { connection } ) ;
77
8- const keepAlive = ( ) => {
8+ const proposal = ( ) => {
99 api . subscribe ( {
1010 proposal : 1 ,
1111 subscribe : 1 ,
@@ -20,15 +20,15 @@ const keepAlive = () => {
2020 } ) ;
2121} ;
2222
23- // Send a ping ever 30 seconds to keep the connection alive, needs to use the same
24- // websocket connection as the one you want to maintain.
23+ // Send a ping every 30 seconds to keep the connection alive
24+ // Needs to use the same websocket connection as the one you want to maintain.
2525const ping = ( ) => {
2626 setInterval ( ( ) => {
2727 api . ping ( ) ;
2828 } , 30000 ) ;
2929} ;
3030
31- const keepAliveRes = async ( res ) => {
31+ const wsResponse = async ( res ) => {
3232 const data = JSON . parse ( res . data ) ;
3333 if ( data . error !== undefined ) {
3434 console . log ( 'Error: %s ' , data . error . message ) ;
@@ -45,14 +45,14 @@ const keepAliveRes = async (res) => {
4545} ;
4646
4747const checkSignal = ( ) => {
48- keepAlive ( ) ;
48+ proposal ( ) ;
4949 ping ( ) ;
50- connection . addEventListener ( 'message' , keepAliveRes ) ;
50+ connection . addEventListener ( 'message' , wsResponse ) ;
5151} ;
5252
5353const endCall = ( ) => {
54- connection . removeEventListener ( 'message' , keepAliveRes , false ) ;
55- keepAlive ( ) . unsubscribe ( ) ;
54+ connection . removeEventListener ( 'message' , wsResponse , false ) ;
55+ proposal ( ) . unsubscribe ( ) ;
5656} ;
5757
5858const keep_alive_button = document . querySelector ( '#keep_alive' ) ;
0 commit comments