Skip to content

API設計(deprecated)

yuta-ike edited this page Oct 22, 2021 · 1 revision

モデル

ChatItemモデル

Messageモデル

type Message = {
  "id": string                   // アイテムID
  "topic_id": string             // トピックID
  "type": "message"              // コメントタイプ
  "icon_id": string              // アイコンID 
  "timestamp": number            // 経過時間のタイムスタンプ
  "content": string              // メッセージの内容
 "is_question": boolean         // 質問コメントかどうか
}

Reactionモデル

type Reaction = {
  "id": string                   // アイテムID
  "topic_id": string             // トピックID
  "type": "reaction"             // コメントタイプ
  "icon_id": string              // アイコンID 
  "timestamp": number            // 経過時間のタイムスタンプ
  "target": {
     "id": string                // リアクションを行なった対象のメッセージID
     "content": string           // リアクションを行なった対象のメッセージの内容
   }
}

ChatItemモデル

type ChatItem = Message | Reaction

Topicモデル

type Topic = {
  "id": string
  "title": string
  "description": string
}

コメントの送受信

コメントを投稿する(POST_CHAT_ITEM

メッセージの場合

Client to Sever

{
  "type": "message"              // アイテムタイプ
  "id": string                   // フロントで生成したアイテムID
  "topic_id": string             // トピックID
  "content": string              // コメントの中身
  "isQuestion": boolean
}

リアクションの場合

Client to Sever

{
  "type": "reaction"             // アイテムタイプ
  "id": string                   // フロントで生成したアイテムID
  "topic_id": string             // トピックID
  "reaction_to_id": string       // リアクションを送るメッセージのID
}

コメントを配信する(PUB_CHAT_ITEM

  • Server to Client
// 入力開始アクション
type InsertEditingAction = {
  type: "insert-editing",
  content: {
    id: string,
    topic_id: string
    icon_id: string
  }
}

// 入力中断アクション
type RemoveEditingAction = {
  type: "remove-editing"
  content: {
    "id": string
    "topic_id": string
  }
}

// 入力完了&チャット送信アクション
type ConfirmToSendAction = {
  type: "confirm-to-send",
  content: ChatItem
}

// チャット送信アクション(何らかの理由で入力中イベントが送信されていない状態でチャットが送信された場合)
type InsertChatItemAction = {
  type: "insert-chatitem",
  content: ChatItem
}
{
  actions: (InsertEditingAction | RemoveEditingAction | ConfirmToSendAction | InsertChatItemAction)[]
}

入力中の表示

入力開始を伝える(START_EDIT

Client to Server

{
  "id": string        // フロントで生成したアイテムID
  "topic_id": string  // トピックID
}

入力終了を伝える(END_EDIT

Client to Server

{
  "id": string        // フロントで生成したアイテムID
  "topic_id": string  // トピックID
}

ルーム参加時

ルームの参加を伝える(ENTER_ROOM

Client to Server

[request]

{
  "room_id": string
  "icon_id": string
}

[response]

{
  "chatItems": Message[]
  "editingInfo": { id: number, topicId: number, iconId: number }[]
  "topics": Topic[]
  "active_user_count": number
}

新規ユーザーの入室を配信する(PUB_ENTER_ROOM

Server to Client

{
  iconId: number
  activeUserCount: number
}

ユーザーの退室を配信する(PUB_LEAVE_ROOM

Server to Client

{
  iconId: number
  activeUserCount: number
}

スタンプ

スタンプを送信する(POST_STAMP

{<empty>}

スタンプを配信する(PUB_STAMP

{
  count: number
}

ルームを建てる

ルームを立てる (BUILD_ROOM

Client to Server

[request]

{
  "topics": Topics[]
}

[response]

{
  "room_id": Topics[]
}