dumb mistake
This commit is contained in:
@@ -63,7 +63,7 @@ function initializeSocket(server) {
|
|||||||
if (result.rows.length > 0) {
|
if (result.rows.length > 0) {
|
||||||
const newMessage = result.rows[0];
|
const newMessage = result.rows[0];
|
||||||
const formattedMessage = `Username: ${newMessage.username}, recipient: ${newMessage.recipient}, message: ${newMessage.content}`;
|
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
|
// 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 });
|
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) {
|
if (result.rows.length > 0) {
|
||||||
//const { username: sender, recipient: receiver, content: content, id: id } = result.rows;
|
//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);
|
socket.emit('messages history', result.rows);
|
||||||
} else {
|
} else {
|
||||||
io.emit('no messages', );
|
io.emit('no messages', );
|
||||||
|
|||||||
2
index.js
2
index.js
@@ -115,7 +115,7 @@ app.get('/', (req, res) => {
|
|||||||
res.sendFile(path.join(__dirname, '/frontend/routes/chat.html'));
|
res.sendFile(path.join(__dirname, '/frontend/routes/chat.html'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
initializeSocket(server)
|
||||||
|
|
||||||
// run server
|
// run server
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user