FIRE WIKI : CanJoinRoom 및 JoinRoom Socket

CanJoinRoom 및 JoinRoom 소켓 관련 문서


이하령 윤영기

Namespace

/room


CanJoinRoom

Room에 join할 수 있는지 체크하는 이벤트

Sender / Receiver:

Sender: client(user)

Receiver: server

Event:

canJoinRoom

Message(Payload)

Type:

json

Required:

room: string;

Optional:

isPublic이 false일 때만 password 필수

password: string

  • 4글자 여야 함

Playload format

메시지 playload가 어떤식으로 보여야 되는지 적습니다.

{
  "room": "16",
  "password": "1111" #private room일 때만
}

Success Response 1:

형식이 올바른데 비번이 맞는 경우, public 방인 경우(password 상관 없음)

Response:

{
    "room": "16",
    "canJoinRoom": true
}

Success Response 2:

형식이 올바른데 비번이 틀린 경우

Response:

{
    "room": "16",
    "canJoinRoom": false
}

Success Response 3:

형식이 올바른데 존재하지 않은 방을 요청한 경우 → 무조건 false

Response:

{
    "room": "1811", <- 존재하지 않는 방
    "canJoinRoom": false
}

룸이 존재하지 않는 경우


Error Response:

형식이 올바르지 않은 경우 exception event 발생.




JoinRoom

채팅 Room에 join하는 이벤트

Sender / Receiver:

Sender: client(user)

Receiver: server

Event:

joinRoom

Message(Payload)

Type:

json

Required:

uid: number; <- 생략하도록 바꿀 예정

room: string;

Optional:

isPublic이 false일 때만 password 필수

password: string

  • 4글자 여야 함

Playload format

메시지 playload가 어떤식으로 보여야 되는지 적습니다.

{
  "uid" : 3,
  "room": "3",
  "password": "1111" #private room일 때만
}

Success Response:

비번이 맞거나 존재하는 공개 방에 성공적으로 참가한 경우

Response: { room : "3" }


Error Response:

이 event는 여러가지 이유로 Fail하거나 Reject될 수 있습니다.

ex. 권한 없음, 잘못된 형식의 payload, 등

Failure에 관한 것은 모두 여기에 적습니다.

Error Type: UNAUTHORIZED

Content: { error : "Log in" }

OR

Error Type: UNPROCESSABLE ENTRY

Content: { error : "Invalid room id" }