채팅 메시지 송신 - DevCamp2Flame/FlameTalk_Server GitHub Wiki
Chat Message API
Request
Method
POST
URL
웹 소켓 연결 /stomp/chat
로 connect 후
/chat/message
Header
Method |
Parameter |
Description |
Content-Type |
application/json |
|
ACCESS-TOKEN |
{accessToken} |
access token값 |
- 현재는 ACCESS-TOKEN 없어도 송신 가능합니다.
Body
Field |
Type |
Description |
Required |
type |
String |
메시지 타입 (INVITE(초대), ENTER(첫 입장), TALK(대화), FILE(파일 전송)) |
Y |
room_id |
String |
채팅방 id |
Y |
sender_id |
String |
발신자 id |
Y |
nickname |
String List |
발신자 별명 |
Y |
contents |
String |
메시지 내용 |
N |
file_url |
String |
파일 url |
N |
- contents or file_url 중 하나만 있어야 올바른 객체입니다.
- TALK 일 경우 contesnts 만 허용, FILE 일 경우 file_url 만 허용
{
"type" : "TALK",
"room_id" : "b49c3059-e509-42d7-add2-9156d87a7db3",
"sender_id" : "1643163512893324414",
"nickname" : "darom",
"contents" : "안녕하세요!"
}
Response
Header
Method |
Parameter |
Description |
statusCode |
{statusCode} |
|
Body
Field |
Type |
Description |
status |
Integer |
응답 코드 |
message |
String |
응답 메세지 |
data |
Object |
생성된 채팅방 정보. data 참고 |
data
Field |
Type |
Description |
message_id |
String |
메시지 id |
room_id |
String |
채팅방 id |
sender_id |
String |
발신자 id |
nickname |
String List |
발신자 별명 |
contents |
String |
메시지 내용 |
file_url |
String |
파일 url |
created_at |
String |
메시지 생성 시각 |
SUCCESS example
{
"status": 201,
"messsage": "채팅",
"data": {
"chatroomId": "b49c3059-e509-42d7-add2-9156d87a7db3",
}
}
Error Code
Code |
Error Messsage |
400 |
Bad Request |
401 |
Unauthorized |
500 |
Server Error |
FAIL example
{
"status": 400,
"message": "잘못된 요청입니다.",
"error": "BAD_REQUEST",
"code": "BAD_REQUEST",
"timestamp": "2022-01-18T19:30:16.3072905",
}