Pong Game Event

aqualung·2023년 8월 23일
0

🎯socket.emit


랜덤매치


randomMatchApply

mode: string;

mode는 게임 난이도로 "easy", "normal", "hard" 셋 중에 하나를 쓰면 됨.
아무것도 넣지 않거나 유효하지 않은 string이 들어왔을 때는 기본값으로 mode = normal로 큐가 잡힘.

다른 mode로 randomMatchApply가 들어오면 기존에 잡고 있던 mode의 랜덤매치큐는 취소됨.
예를 들어 "easy"로 랜덤매치를 잡던 도중 randomMatchApply("hard")가 들어오면 기존 easy매칭은 취소되고 "hard" 매칭을 잡게 됨.


randomMatchCancel

-

랜덤매칭 취소


1대1 매치


oneOnOneApply

{
	from: string; // 닉네임
    to: string;
    mode: string; // easy normal hard
}

상대 유저가 connected라면 양 쪽 유저에게
'updateInvitationList'이벤트를 emit함.


oneOnOneAccept

{
	from: string;
    fromId: number;
    to: string;
    toId: number;
    mode: string;
}

상대 유저가 connected라면 양 쪽 유저에게
'matchStartCheck'이벤트를 emit하고,
'updateInvitationList'이벤트를 emit함.


oneOnOneDecline

{
	from: string;
    fromId: number;
    to: string;
    toId: number;
    mode: string;
}

양 쪽 유저에게
'updateInvitationList'이벤트를 emit함.


매치 수락


matchAccept

roomName: string;

'matchStartCheck' 이벤트를 받았을 때 매치를 수락

matchDecline

roomName: string;

'matchStartCheck' 이벤트를 받았을 때 매치를 거절


닉네임 변경


changeNick

nickname: string;


🎯socket.on


매치 수락 확인


matchStartCheck

{
  roomName: string;
  player: string[]; // [ nickname_1, nickname_2 ]
  mode: string;
}

랜덤매칭 또는 1대1매칭이 잡혔을 때 게임을 시작할 건지 확인


matchDecline

roomName: string;

'matchStartCheck' 후에 상대방이 매칭을 거절 했을 때


초대장 목록


updateInvitationList

array[] of

{
	from: string; // 닉네임
    fromId: number;
    to: string;
    toId: number;
    mode: string; // easy normal hard
}

초대장 목록 전송

0개의 댓글

관련 채용 정보