fix: Update prodServer.ts to match websocketConfig.ts
This commit is contained in:
parent
0034f594ea
commit
b6ec0312d5
@ -18,14 +18,20 @@ io.on('connection', async (socket) => {
|
|||||||
if (msg.content !== '') {
|
if (msg.content !== '') {
|
||||||
console.log(`\x1b[35m[ws:kit]\x1b[0m message from ${socket.id}: ${msg.content}`);
|
console.log(`\x1b[35m[ws:kit]\x1b[0m message from ${socket.id}: ${msg.content}`);
|
||||||
// Store the message in the database
|
// Store the message in the database
|
||||||
await db.sendMessage('000', msg.content, msg.id, uuidv4());
|
await db.sendMessage(msg.channel, msg.content, msg.id, uuidv4());
|
||||||
io!.emit('message', {
|
io!.emit('message', {
|
||||||
user: msg.id,
|
user: msg.id,
|
||||||
message: msg.content,
|
message: msg.content,
|
||||||
imageSrc: 'https://www.arithefirst.com/images/pfp.png',
|
imageSrc: `https://api.dicebear.com/9.x/identicon/svg?seed=${msg.id}`,
|
||||||
|
channel: msg.channel,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Runs on client disconnect
|
||||||
|
socket.on('disconnect', () => {
|
||||||
|
console.log(`\x1b[35m[ws:kit]\x1b[0m client disconnected (${socket.id})`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
@ -2,7 +2,7 @@ import { Server as SocketIOServer } from 'socket.io';
|
|||||||
import type { HttpServer } from 'vite';
|
import type { HttpServer } from 'vite';
|
||||||
// Don't try to replace with $lib alias. Since this
|
// Don't try to replace with $lib alias. Since this
|
||||||
// file gets loaded as a vite plugin, it will crash
|
// file gets loaded as a vite plugin, it will crash
|
||||||
import { db } from '$lib/server/db';
|
import { db } from '../server/db';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
let io: SocketIOServer | undefined;
|
let io: SocketIOServer | undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user