this is a pain in the ass
This commit is contained in:
26
server.ts
26
server.ts
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user