Socket.io. How to connect and upload user id

Asked

Viewed 30 times

1

By default the socket.io generates a unique id. I need this id to be the same id as the user in the database. Have any way to set the id?

if not, how my client front recovers the id generated by the socket?

Front codes

this.socket = Ws(wsUrl, {});
this.connection = this.socket.connect(); //qual o id conectado?
this.chat = this.socket.subscribe('chat');

Code api adonisjs

constructor({ socket, request }) {
    this.socket = socket;
    this.request = request;
    console.log(socket.id) //id do client 
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.