[1] 특정 클라이언트가 채팅방을 생성하고 참여 및 레디해서 시작하고 게임종료까지의 과정
[2] 랜덤 클라이언트 매칭 , 채팅방 생성 참여 레디 게임 종료 까지의 과정
API 요청 방법 및 응답 형태
handleConnection
token
parameter
X
response
{
"message": "fake_U1 연결",
"user": {
"id": 125,
"username": "fake_U1",
"rank": 100,
"status": 2
}
}
handleDisconnect
parameter
X
response
findGameRooms(on, emit) = 서버 기준 구현된 기능 socket.on(’findGameRooms’) , socket.emit(’findGameRooms’)
parameter
X
response
{
"gameRoom": [
{
"gameRoomName": "게임룸",
"gameStatus": 0,
"players": [],
"spectators": [],
"facts": {
"display": {
"width": 1920,
"height": 1080
},
"ball": {
"speed": 20,
"radius": 20
},
"touchBar": {
"width": 20,
"height": 200,
"x": 50
},
"score": {
"y": 15,
"max": 10
},
"gameOption": {
"backgroundColor": 0,
"mode": 0
}
},
"playing": {
"ball": {
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"speed": 0
}
}
}
]
}
randomGameMatch(on, emit)
parameter
X
response
{
"message": "랜덤 매칭 된 룸 이름입니다.",
"gameRoom": {
"gameRoomName": "350358199",
"gameStatus": 1,
"players": [
{
"user": {
"id": 71,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 2
},
"gameRoomName": "350358199",
"gameOption": null,
"touchBar": 540,
"score": 0
},
{
"user": {
"id": 73,
"username": "fake_U2",
"username42": null,
"rating": 1000,
"status": 0
},
"gameRoomName": "350358199",
"gameOption": null,
"touchBar": 540,
"score": 0
}
],
"spectators": [],
"facts": {
"display": {
"width": 1920,
"height": 1080
},
"ball": {
"speed": 20,
"radius": 20
},
"touchBar": {
"width": 20,
"height": 200,
"x": 50
},
"score": {
"y": 15,
"max": 10
},
"gameOption": {
"backgroundColor": 0,
"mode": 0
}
},
"playing": {
"ball": {
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"speed": 0
}
}
}
}
touchBar(on, emit)
parameter
{"touchBar":10 ,"gameRoomName":"게임룸"}
emit
{
"message": "touchBar",
"player": 126,
"touchBar": 10
}
removeSocketInQueue(on, emit)
parameter
x
emit
{
"message": "removeSocketInQueue",
}
createGameRoom (랜덤 생성된 채널이름 = 개발자 관점 데이터 식별) (on, emit)
parameter
x
response
{
"message": "게임룸 게임룸이 생성되었습니다.",
"gameRoom": {
"gameRoomName": "122313231213",
"gameStatus": 0,
"players": [],
"spectators": [],
"facts": {
"display": {
"width": 1920,
"height": 1080
},
"ball": {
"speed": 20,
"radius": 20
},
"touchBar": {
"width": 20,
"height": 200,
"x": 50
},
"score": {
"y": 15,
"max": 10
},
"gameOption": {
"backgroundColor": 0,
"mode": 0
}
},
"playing": {
"ball": {
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"speed": 0
}
}
}
}
joinGameRoom(on, emit)
parameter
{"gameRoomName": "122313231213"}
response
{
"message": "122313231213 게임룸에 fake_U1 플레이어가 들어왔습니다.",
"gameRoom": {
"gameRoomName": "122313231213",
"gameStatus": 0,
"players": [
{
"user": {
"id": 125,
"username": "fake_U1",
"rank": 100,
"status": 2
},
"gameRoomName": "122313231213",
"gameOption": null,
"touchBar": 540,
"score": 0
}
],
"spectators": [],
"facts": {
"display": {
"width": 1920,
"height": 1080
},
"ball": {
"speed": 20,
"radius": 20
},
"touchBar": {
"width": 20,
"height": 200,
"x": 50
},
"score": {
"y": 15,
"max": 10
},
"gameOption": {
"backgroundColor": 0,
"mode": 0
}
},
"playing": {
"ball": {
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"speed": 0
}
}
}
}
readyGame(on, emit)
wait(emit) = 서버 기준 구현된 기능 socket.emit(’wait’)
parameter
{"backgroundColor":2, "mode":1, "gameRoomName":"461180221"}
response
"message": "양 쪽 유저 게임 준비 완료",
"gameRoom": {
"gameRoomName": "461180221",
"gameStatus": 2,
"players": [
{
"user": {
"id": 259,
"username": "fake_U2",
"username42": null,
"rating": 1000,
"status": 1
},
"gameRoomName": "461180221",
"gameOption": {
"backgroundColor": 2,
"mode": 1
},
"touchBar": 540,
"score": 0
},
{
"user": {
"id": 258,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 1
},
"gameRoomName": "461180221",
"gameOption": {
"backgroundColor": 2,
"mode": 1
},
"touchBar": 540,
"score": 0
}
],
"spectators": [],
"facts": {
"display": {
"width": 1920,
"height": 1080
},
"ball": {
"speed": 40,
"radius": 20
},
"touchBar": {
"width": 20,
"height": 200,
"x": 50
},
"score": {
"y": 15,
"max": 10
},
"gameOption": {
"backgroundColor": 2,
"mode": 1
}
},
"playing": {
"ball": {
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"speed": 0
}
}
}
}
startGame(on)
ball(emit)
score(emit)
parameter
{ "gameRoomName": "122313231213"}
response (ball)
response (score)
response (gameOver)
exitGameRoom(on, emit)