-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: socket.io-client, uuid 라이브러리 설치 * feat: game gateway 이벤트 추가 - 방장 접속 - 참여자 접속 - sid 쿠키 설정 * feat: master entry 이벤트 구현 * feat: participant entry 이벤트 구현 --------- Co-authored-by: dooohun <[email protected]>
- Loading branch information
Showing
15 changed files
with
237 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function getCookie(name: string) { | ||
const value = `; ${document.cookie}`; | ||
const parts = value.split(`; ${name}=`); | ||
|
||
if (parts.length === 2) { | ||
return parts.pop()?.split(';').shift(); | ||
} | ||
return undefined; | ||
} | ||
|
||
export function setCookie(name: string, val: any, day?: number) { | ||
const date = new Date(); | ||
const value = val; | ||
// day가 없는 경우 세션쿠키로 설정 | ||
if (day) { | ||
date.setTime(date.getTime() + day * 24 * 60 * 60 * 1000); | ||
document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`; | ||
} else { | ||
document.cookie = `${name}=${value}; path=/`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { io, Socket } from 'socket.io-client'; | ||
|
||
let socket: Socket | null = null; | ||
|
||
export function getQuizSocket(): Socket { | ||
if (!socket) { | ||
socket = io('http://localhost:3000/game'); | ||
} | ||
return socket; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable, HttpException, HttpStatus, Param } from '@nestjs/common'; | ||
import { ChoiceRepository } from '../../quiz/quizzes/repositories/choice.repository'; | ||
import { ClassRepository } from '../../quiz/quizzes/repositories/class.repository'; | ||
import { QuizRepository } from '../../quiz/quizzes/repositories/quiz.repository'; | ||
|
||
@Injectable() | ||
export class GameService { | ||
constructor( | ||
private readonly classRepository: ClassRepository, | ||
private readonly quizRepository: QuizRepository, | ||
private readonly choiceRepository: ChoiceRepository, | ||
) {} | ||
|
||
async cachingQuizData(classId: number) { | ||
const classWithRelations = await this.classRepository.findClassWithRelations(classId); | ||
|
||
return classWithRelations; | ||
} | ||
} |
Oops, something went wrong.