[1] 채팅 로직 순서
[2] DM로직 순서
[3] 채팅방에서 게임초대 로직 순서 (채팅소켓 + 게임소켓)
emit, on 은 클라이언트 기준
1. :
-> 초대하는 유저 채팅 소켓 연결 + 초대받는 유저 채팅소켓 연결
-> 초대하려는 유저 socket.emit(createInviteRoom)
-> 초대 받는 유저 socket.on(requestInvite))
-> 초대하려는 유저, 초대 받는 유저 socket.on(requestInvite)
2.
-> 초대 받는 유저 socket.emit(responseInvite)
-> 초대 하는 유저 socket.on(responseInviteToHost)
3.
-> 초대 하는 유저 게임소켓 연결
-> 초대 하는 유저 socket.emit(createGameRoom)
-> 초대 하는 유저 socket.emit(joinGameRoom)
-> 초대 하는 유저 socket.emit(inviteGameRoomInfo)
4.
-> 초대 받는 유저 socket.on(inviteGameRoomInfo)
-> 초대 받는 유저 게임소겟 연결
-> 초대 받는 유저 socket.emit(joinGameRoom) (편집
chatRoomStatus
connection (on, emit)
token
parameter
x
response
{
"message": "fake_U1 연결",
"user": {
"id": 125,
"username": "fake_U1",
"rank": 100,
"status": 0
},
"chatRooms": [],
"chatRoomsDm": [],
"allChatRooms": [
{
"id": 82,
"name": "채팅룸 1"
},
{
"id": 83,
"name": "채팅룸 2"
},
{
"id": 84,
"name": "채팅룸 3"
},
{
"id": 85,
"name": "채팅룸 4"
},
{
"id": 89,
"name": "채팅룸 50"
}
]
}
disconnect(on, emit)
parameter
response
on.createChatRoom (on, emit) = 서버 기준 구현된 기능 socket.on(’createChatRoom’) , socket.emit(’createChatRoom’)
{ "name": "채팅룸 1", "status": 2, "password": "1234"}//protected
{ "name": "채팅룸 2", "status": 0, "password": ""}//public
{
"message": "채팅룸이 생성되었습니다",
"chatRoom": {
"name": "채팅룸 5",
"status": 2,
"owner": {
"id": 125,
"username": "fake_U1",
"rank": 100,
"status": 4
},
"adminUser": [],
"joinedUser": [],
"mutedUser": [],
"bannedUser": [],
"id": 90
}
}
join (on, emit)
채팅룸 5방에 fake_U1이/가 들어왔습니다
updatePwd (on, emit)
{
"chatRoomId": 310,
"oldPwd": "1234",
"newPwd": "12345"
}
{message:`채팅방 비밀번호 변경 완료`}
chatRoomAll(on, emit)
parameter
x
response
{
"message": "모든 채팅 방 목록",
"chatRoom": [
{
"id": 82,
"name": "채팅룸 1",
"owner": {
"id": 44,
"username": "fake_U2",
"username42": null,
"rating": 1000,
"status": 2
}
},
{
"id": 83,
"name": "채팅룸 2",
"owner": {
"id": 44,
"username": "fake_U3",
"username42": null,
"rating": 1000,
"status": 2
},
{
"id": 84,
"name": "채팅룸 3",
"owner": {
"id": 45,
"username": "fake_U4",
"username42": null,
"rating": 1000,
"status": 2
},
{
"id": 85,
"name": "채팅룸 4",
"owner": {
"id": 46,
"username": "fake_U5",
"username42": null,
"rating": 1000,
"status": 2
},
{
"id": 89,
"name": "채팅룸 50",
"owner": {
"id": 47,
"username": "fake_U6",
"username42": null,
"rating": 1000,
"status": 2
}
]
}
DB에서 limit , skip?
chatRoomById (on, emit)
parameter
{"chatRoomId":22}
response
{
"message": "채팅룸 10 방 정보",
"chatRoom": {
"id": 22,
"name": "채팅룸 10",
"status": 0,
"mutedUser": [],
"bannedUser": [],
"joinedUser": [
{
"id": 20,
"user": {
"id": 49,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 2
}
},
{
"id": 21,
"user": {
"id": 50,
"username": "fake_U2",
"username42": null,
"rating": 1000,
"status": 2
}
}
],
"adminUser": [
{
"id": 17,
"user": {
"id": 49,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 2
}
}
],
"owner": {
"id": 49,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 2
},
"chatLog": [
{
"id": 5,
"message": "보내는 메시지 by user2",
"createdAt": "2023-01-02T01:07:05.070Z",
"user": {
"id": 50,
"username": "fake_U2",
"username42": null,
"rating": 1000,
"status": 2
}
},
{
"id": 6,
"message": "보내는 메시지 by user1",
"createdAt": "2023-01-02T01:07:14.893Z",
"user": {
"id": 49,
"username": "fake_U1",
"username42": null,
"rating": 1000,
"status": 2
}
}
]
}
}
chatRoomByName(on, emit)
parameter
{"chatRoomName":"채팅룸 1"}
response
{
"message": "채팅룸 1 방 정보",
"chatRoom": {
"id": 82,
"name": "채팅룸 1",
"status": 2,
"mutedUser": [],
"bannedUser": [],
"joinedUser": [],
"adminUser": [],
"owner": {
"id": 86,
"username": "jeonghwl",
"rank": 100,
"status": 3
},
}
}
chatRoomByUserId(on, emit)
parameter
{"userId":86}
response
chatRoomMe(on, emit)
join(on, emit)
leave(on, emit)
message(on, emit)