this is a pain in the ass

This commit is contained in:
Gavin McDonald
2025-06-23 15:33:04 -04:00
parent 59aa904c5a
commit aa938f7258
6 changed files with 377 additions and 20 deletions

View File

@@ -119,6 +119,32 @@ app.prepare().then(() => {
}
});
socket.on('rtc-answer', ({ gameID, answer }: { gameID: string; answer: any }) => {
try {
const gameState = gameStore.getGame(gameID);
console.log('[rtc-answer]', gameID);
io.to(gameState.dmID).emit('rtc-answered', answer);
io.to(gameState.spectatorID).emit('rtc-answered', answer);
} catch (e) {
const error = e instanceof Error ? e.message : e;
console.error(Date.now(), 'Error[rtc-answer]', error);
}
});
socket.on('rtc-offer', ({ gameID, offer }: { gameID: string; offer: any }) => {
try {
const gameState = gameStore.getGame(gameID);
console.log('[rtc-offer]', gameID);
io.to(gameState.dmID).emit('rtc-offered', offer);
io.to(gameState.spectatorID).emit('rtc-offered', offer);
} catch (e) {
const error = e instanceof Error ? e.message : e;
console.error(Date.now(), 'Error[rtc-offer]', error);
}
});
socket.on('disconnect', () => {
try {
const game = gameStore.playerExit(socket.id);