Skip to content

Commit

Permalink
fix: set room timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
SpongeBed81 committed Jun 21, 2024
1 parent 7fcab6d commit 2d89c88
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/events/login.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Socket } from 'socket.io';
import { z } from 'zod';

import { io } from '@index';
Expand Down Expand Up @@ -40,7 +41,7 @@ const validation = z.object({
});

export default class Login {
async handle({ socket, callback, data }) {
async handle({ socket, callback, data }: { socket: Socket; callback: any; data: any }) {
const token = data?.token || socket.handshake.headers.authorization;

const val = validation.safeParse({
Expand Down
3 changes: 2 additions & 1 deletion src/events/playerTimestamp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Socket } from 'socket.io';

import { get } from '@utils/cache';
import { get, set } from '@utils/cache';

import { Participant } from './login';

Expand Down Expand Up @@ -31,6 +31,7 @@ export default class MuteOrUnmuteParticipant {

if (pass) {
socket.broadcast.to(room).emit('playerTimestamp', { timestamp: videoTimestamp });
await set(`room:${room}:timestamp`, videoTimestamp);
}
}
}
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const chatBotProps = {
(async () => {
const events = await traverseEvents();

app.get('/', (res, _) => {
res.writeStatus('200 OK').end('obezanime watch together socket 👌');
});

io.attachApp(app, {
cors: {
origin: process.env.CORS_ORIGIN,
Expand Down

0 comments on commit 2d89c88

Please sign in to comment.