Answer the question
In order to leave comments, you need to log in
Is it possible to use response and request in socket.io?
In general, I am learning to use Socket.io.
I'm making a chat, but so far I can't see who sent the message. I want to pull the user login from the session,
but I don't know how to use request in socket.io to do something like this:
const login = req.session.user.login
If the login from the session can be obtained somehow differently, then please tell me how.
Answer the question
In order to leave comments, you need to log in
front
this.socket.emit('new-message', {
chat: {
name: this.$route.params.id
},
user: {
name: this.UserInfo.login
},
message: this.NewMessage,
});
socket.on('new-message', data => {
io.emit('update-chat', {
user: data.user.name,
message: data.message,
date: date,
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question