dumb mistake

This commit is contained in:
slawk0
2024-08-29 23:31:05 +02:00
parent 59afc621b4
commit 1921b4f5a5
2 changed files with 3 additions and 3 deletions

View File

@@ -63,7 +63,7 @@ function initializeSocket(server) {
if (result.rows.length > 0) {
const newMessage = result.rows[0];
const formattedMessage = `Username: ${newMessage.username}, recipient: ${newMessage.recipient}, message: ${newMessage.content}`;
console.log(formattedMessage);
//console.log(formattedMessage);
// Emit message to the sender's and recipient's rooms
io.to(username).to(recipient).emit('chat message', { username: newMessage.username, recipient: newMessage.recipient, content: newMessage.content });
@@ -103,7 +103,7 @@ function initializeSocket(server) {
if (result.rows.length > 0) {
//const { username: sender, recipient: receiver, content: content, id: id } = result.rows;
console.log('Sending historical messages:', result.rows);
console.log('Sending historical messages');
socket.emit('messages history', result.rows);
} else {
io.emit('no messages', );

View File

@@ -115,7 +115,7 @@ app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '/frontend/routes/chat.html'));
});
});
initializeSocket(server)
// run server
server.listen(port, () => {