Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Virtru Secure Chat 2/3: Application Bootstrap
try {
const user = socket.nickname;
if (!user) throw new Error('Your session is not registered. Please make sure to login.');
const response = await pouchDB.addMessage(channel, message, user);
const payload = { ...response, message, user };
// Send ok response
socket.emit('add-message-ok', response);
// Broadcast message to room
socket.broadcast.to(channel).emit('new-message', payload);
// Send new message to user
socket.emit('new-message', payload);
} catch (e) {
// Send error response
socket.emit('add-message-error', e.message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.