Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Bit-Barron committed Nov 2, 2024
1 parent a38e8d4 commit c437967
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
16 changes: 4 additions & 12 deletions src/lib/server/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ export const initSocketIO = (httpServer: HTTPServer): Promise<Server> => {
if (!io) {
console.log('Initializing Socket.IO server...');
io = new Server(httpServer, {
path: '/socket.io/',
path: '/socket.io',
cors: {
origin: dev ? ['http://localhost:3000'] : ['https://youtubepedia.barron.agency'],
methods: ['GET', 'POST'],
credentials: true
},
transports: ['websocket', 'polling'],
pingTimeout: 60000,
pingInterval: 25000,
connectTimeout: 45000,
allowEIO3: true
transports: ['websocket', 'polling']
});

io.on('connection', (socket) => {
Expand All @@ -33,12 +29,8 @@ export const initSocketIO = (httpServer: HTTPServer): Promise<Server> => {
console.log(`User ${userId} joined their room`);
}

socket.on('error', (error) => {
console.error('Socket error:', error);
});

socket.on('disconnect', (reason) => {
console.log(`Client disconnected (${reason})`, socket.id);
socket.on('disconnect', () => {
console.log('Client disconnected', socket.id);
});
});

Expand Down
3 changes: 1 addition & 2 deletions src/routes/(main)/dashboard/chat/[id]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ export const actions = {
});

const io = getIO();
const working = io.to(userId).emit('new-question', questionChat);
io.to(userId).emit('new-question', questionChat);

console.log(working);
const response = await fetch('/api/ask', {
method: 'POST',
headers: {
Expand Down
14 changes: 4 additions & 10 deletions src/routes/(main)/dashboard/chat/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,10 @@
</script>

<div class="container mx-auto px-4 py-8">
<Card class="mb-8">
<CardContent class="p-6">
<h2 class="mb-4 text-xl font-semibold">Transcript</h2>
<div
class="max-h-64 overflow-y-auto whitespace-pre-wrap rounded-lg border border-gray-200 p-4"
>
{data.transcript.content}
</div>
</CardContent>
</Card>
<h2 class="mb-4 text-xl font-semibold">Transcript</h2>
<div class="max-h-64 overflow-y-auto whitespace-pre-wrap rounded-lg border p-4">
{data.transcript.content}
</div>

<Card class="mb-8">
<CardContent class="p-6">
Expand Down

0 comments on commit c437967

Please sign in to comment.