Client Side Messages

Message - REQUESTED

Requests associating Websocket connection with Session Record. If the session does not exist in the database, server sends Message - EXPIRED, if a session exists, connection ID is being assigned and Message - OK is sent.

Please see the examples below to see how to successfully send REQUESTED messages.

const client = new WebSocket('wss://drisc-cleng.com?token=<jwt_token>');

//some of code removed for clarity

client.send(JSON.stringify({ action: "REQUESTED" }))

client.on('message', (response) => {
  const data = JSON.parse(response.data)
  switch(data.action) {
    case 'OK':
      // start streaming content
      break;
    case 'EXPIRED':
      // display error message
      break;
    //some of code removed for clarity
  }
})
wscat -c 'wss://drisc-cleeng.com?token=<jwt_token>'
Connected (press CTRL+C to quit)
> {"action":"REQUESTED"}

// Success response
< {"action":"OK"}

// Failed response
< {"action":"EXPIRED"}

Message - PONG

Response to server Message - PING message. Allows the server to detect not responding connections. Implementing this message is crucial for DRISC to be fully functional

Please see the examples below to see how to successfully send PONG messages.

const client = new WebSocket('wss://drisc-cleng.com?token=<jwt_token>');

//some of code removed for clarity

client.on('message', (response) => {
  const data = JSON.parse(response.data)
  switch(data.action) {
    case 'PING':
      client.send(JSON.stringify({ action: "PONG" }))
      break;
  }
})
$ wscat -c 'wss://drisc-cleeng.com?token=<jwt_token>'
Connected (press CTRL+C to quit)
< {"action":"PING"}
> {"action":"PONG"}

Message - FINISHED

Informs DRISC about content stream end. The server removes records from the database effectively freeing the slot as well as forcing to create a new session if the client application wants to access resources again.

Please see the examples below to see how to successfully send FINISHED message.

const client = new WebSocket('wss://drisc-cleng.com?token=<jwt_token>');

//some of code removed for clarity

client.send(JSON.stringify({ action: "FINISHED" }))
$ wscat -c 'wss://drisc-cleeng.com?token=<jwt_token>'
Connected (press CTRL+C to quit)
> {"action":"FINISHED"}

Did this page help you?