Websocket - How to get Packet Code

Hi.

I’m starting to work with Adonis WS and I would like to know how I can get the packet code, the “t” value.

The code below is part of a Vue Component:

created(){
  this.ws = Ws('ws://localhost:3333')

  this.ws
    .withJwtToken(this.$store.getters.token)
    .connect()

  this.ws.on('open',()=>{
    console.log('open');
    this.chat = this.ws.subscribe('chat')

    this.chat.on('ready', () => {
      this.chat.emit('message', 'hello')
      console.log('connected');
    })

    this.chat.on('error', (error) => {
      console.log(error); // If jwt is expired I get the message, I can see the "t" value on the browser devtools but not in the console..
    })        
  })

  this.ws.on('error', (error) => {
    console.log(error);
    //the connection doesn't know that jwt is expired, why?
  })

},

const packets = require(’@adonisjs/websocket-packets’)

1 Like