이 문서는 Socket.IO를 사용한 실시간 게임 서버와 클라이언트 간의 통신 명세를 정의합니다. 클라이언트는 Unity로 개발되며, 서버는 Node.js와 Socket.IO를 사용합니다.
ws://[서버주소]:[포트]
{
transports: ['websocket']
}
이벤트명 | 데이터 형식 | 설명 |
---|---|---|
registerPlayer |
{ nickname: string, rating: number, imageIndex: number } |
플레이어 정보를 등록하고 매칭 시작 |
leaveRoom |
{ roomId: string } |
현재 방에서 나가기 |
이벤트명 | 데이터 형식 | 설명 |
---|---|---|
doPlayer |
{ roomId: string, position: { x: number, y: number } } |
플레이어의 움직임 전송 |
이벤트명 | 데이터 형식 | 설명 |
---|---|---|
requestSurrender |
{ roomId: string } |
항복 요청 |
requestDraw |
{ roomId: string } |
무승부 요청 |
acceptDraw |
{ roomId: string } |
무승부 수락 |
rejectDraw |
{ roomId: string } |
무승부 거절 |
requestRevenge |
{ roomId: string } |
재대결 요청 |
acceptRevenge |
{ roomId: string } |
재대결 수락 |
rejectRevenge |
{ roomId: string } |
재대결 거절 |
이벤트명 | 데이터 형식 | 설명 |
---|---|---|
createRoom |
{ roomId: string, message: string } |
방 생성 완료 (대기 중) |
joinRoom |
`{ roomId: string, opponentRating: number, opponentNickname: string, | |
opponentImageIndex: number, | ||
isBlack : bool }` | 이미 있는 방에 입장 | |
startGame |
`{ opponentId: string, opponentRating: number, opponentNickname: string, | |
opponentImageIndex: number, | ||
isBlack : bool }` | 상대방이 입장하여 게임 시작 | |
exitRoom |
{} |
방에서 나가기 완료 |
endGame |
{} |
게임 종료 (상대방이 방을 나감) |
switchAI |
{ message: string } |
매칭 타임아웃 AI로 전환 신호 |
이벤트명 | 데이터 형식 | 설명 |
---|---|---|
doOpponent |
{ position: { x: number, y: number } } |
상대방 움직임 수신 |