소켓 명세

export interface ChatLog {
  chatId: string;
  message: string;
  userId: string; //type이 message가 아닌 경우 안들어옴
  type: 'message' | 'in' | 'out' | 'kick';
  time: Date;
}

export interface UserInfo {
  userId: string;
  profileImg: string | null;
  nickname: string;
  isLeader: boolean;
  isLeave: boolean;
  lastChatLogId: string; -> ChatLog의 _id
  isMe: boolean;
}

export interface RoomInfo {
  brandName: string;
  branchName: string;
  regionName: string; //CONCAT 필요
  themeName: string;
  themeId: string; //시간표 불러올 때 사용
  posterImageUrl: string;
  recruitmentContent: string;
  appointmentDate: string;
  recruitmentMembers: number;
  currentMembers: number;
  recruitmentCompleted: boolean;
  appointmentCompleted: boolean;
	website: string;
}

최초 이벤트가 FE

FE

emit

BE

on

최초 이벤트가 BE

FE

on

BE

emit

  1. 프 →백 : join (roomId, JWT Token)

  2. 백: join받아서 JWT+roomId 진짜 이사람이 이 방 사람인지 검증+ 방 정보를 가져옴

  3. 백 → 프 : userListInfo, roomInfo

  4. 프 →백 : join (roomId, JWT Token)

  5. 백: join받아서 JWT+roomId 진짜 이사람이 이 방 사람인지 검증 후 userListInfo

프론트

socket.emit('join',roomId,token,(res)=>{
	if(res !== 'ok')
     socket.disconnect();
}
socket.on('connect', () => {
  connectedSocket.emit('join', { roomId: param }, (res: any) => console.log(res));
});

socket.on("event", (res) => {
});
socket.on("joinRes", (res) => res === 'ok')
socket.on('userListInfo')
socket.on('roomInfo')
socket.on('chat')

백 채팅리스트

mysql mongdb

Untitled

창한