Skip to content

API Docs ‐ GroupOrder

6suhyeon edited this page May 12, 2025 · 3 revisions

API Documentation

클라이언트 → 서버 (AppMessageType)

  • MENUADD: 메뉴 수량 증가
  • MENUSUB: 메뉴 수량 감소
  • STARTORDER: 주문 시작
  • UNSUB: 구독 취소 요청

서버 → 클라이언트 (TopicMessageType)

  • INIT: 초기 정보
  • MENUUPDATE: 메뉴 수량 변경
  • MEMBERUPDATE: 참여자 수 변경
  • UNSUB: 구독 취소 확인
  • STARTORDER: 주문 시작 알림
  • TIMEUPDATE: 세션 시간 업데이트
  • PRESESSIONEND: 세션 종료 1분 전
  • SESSIONEND: 세션 종료
  • ERROR: 오류 메시지

연결 엔드포인트

  • 웹소켓 연결: ws://server-url/ws

메시지 형식

모든 메시지는 JSON 형식을 사용

{
  "type": "메시지 타입", 
  "boothId": "UUID boothId",
  "tableNum": "테이블 번호",
  "payload": {"메시지 타입에 따른 데이터 구분"}
}

상황별 API

1. 주문 참여 (연결 및 구독)

사용자가 QR코드를 스캔하여 주문 페이지에 접속할 때

Request (클라이언트 → 서버)

STOMP 명령: SUBSCRIBE

header :


destination: /topic/{boothId}/{tableNum}

message: None

Response 1 (서버 → 해당 클라이언트)

STOMP 명령: MESSAGE

header:


destination: /user/{sessionId}/topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "INIT",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "memberCount": "Integer",
    "totalPrice": "Integer",
    "totalCount": "Integer",
    "remainingMinutes" : "Integer", 
    "menuList": [
      {
        "menuId": "UUID-1",
        "menuCount": "Integer"
      },
      {
        "menuId": "UUID-2",
        "menuCount": "Integer"
      }
    ]
  }
}

Response 2 (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header:


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "MEMBERUPDATE",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "memberCount": "Integer"
  }
}

2. 메뉴 수량 증가

사용자가 메뉴 수량 증가(+) 버튼을 클릭할 때 발생

Request (클라이언트 → 서버)

STOMP 명령: SEND

header :


destination: /app/order
content-type: application/json

message :

{
  "type": "MENUADD",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "menuId": "UUID-1"
    "menuCount": "Integer",
    "totalPrice": "Integer",
    "totalCount": "Integer"
  }
}

Response (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "MENUUPDATE",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "menuId": "UUID-1",
    "menuCount": "Integer",
    "totalPrice": "Integer",
    "totalCount": "Integer"
  }
}

3. 메뉴 수량 감소

사용자가 메뉴 수량 감소(-) 버튼을 클릭할 때 발생

Request(클라이언트 → 서버)

STOMP 명령: SEND

header :


destination: /app/order
content-type: application/json

message :

{
  "type": "MENUSUB",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "menuId": "UUID-1",
    "menuCount": "Integer",
    "totalPrice": "Integer",
    "totalCount": "Integer"
  }
}

Response (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "MENUUPDATE",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "menuId": "UUID-1",
    "menuCount": "Integer",
    "totalPrice": "Integer",
    "totalCount": "Integer"
  }
}

4. 주문 시작(결제)

사용자가 주문하기 버튼을 클릭할 때 발생

Request (클라이언트 → 서버)

STOMP 명령: SEND

header :


destination: /app/order
content-type: application/json

message :

{
  "type": "STARTORDER",
  "boothId": "UUID",
  "tableNum": "Integer"
}

Response (서버 → 주문 시작자 외 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "STARTORDER",
  "boothId": "UUID",
  "tableNum": "Integer"
}

5. 구독 취소 (연결 종료)

사용자가 주문 페이지를 나가거나, 취소 버튼을 클릭할 때 발생

Request (클라이언트 → 서버)

STOMP 명령: SEND

header:


destination: /app/order
content-type: application/json

message :

{
  "type": "UNSUB",
  "boothId": "UUID",
  "tableNum": "Integer"
}

Response 1 (서버 → 해당 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /user/{sessionId}/topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "UNSUB",
  "boothId": "UUID",
  "tableNum": "Integer"
}

Response 2 (서버 → 나머지 클라이언트)

STOMP 명령: MESSAGE

헤더:


destination: /topic/{boothId}/{tableNum}
content-type: application/json

본문:

{
  "type": "MEMBERUPDATE",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "memberCount": "Integer"
  }
}

6. 세션 시간 업데이트

서버에서 1분마다 세션 남은 시간을 클라이언트에게 전송

Request : 없음 (서버 자동 전송)

Response (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "TIMEUPDATE",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "remainingMinutes": "Integer"
  }
}

7. 세션 종료 1분 전 알림

세션 종료 1분 전에 서버에서 클라이언트에게 알림

Request : 없음 (서버 자동 전송)

Response (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "PRESESSIONEND",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "remainingMinutes": 1
  }
}

8. 세션 종료

세션 제한 시간 10분이 지나면 서버에서 세션을 종료하고 클라이언트에게 알림

Request : 없음 (서버 자동 전송)

Response (서버 → 모든 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "SESSIONEND",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": {
    "remainingMinutes": 0
  }
}

9. 오류 메시지

서버에서 오류가 발생한 경우 클라이언트에게 알림

Request : 없음 (서버 자동 전송)

Response (서버 → 모든 클라이언트 또는 특정 클라이언트)

STOMP 명령: MESSAGE

header :


destination: /topic/{boothId}/{tableNum}
content-type: application/json

message :

{
  "type": "ERROR",
  "boothId": "UUID",
  "tableNum": "Integer",
  "payload": "요청 처리 중 오류 발생: [오류 메시지]"
}

Clone this wiki locally