export const SVC_TYPE_FILE = 53; // File
export const SSVC_TYPE_FILE_INFO_REQ = 1; // File 정보 전송 요청
export const SSVC_TYPE_FILE_INFO_DATA = 2; // File 정보 Data
export const SSVC_TYPE_FILE_INFO_CHECK_DATA = 3; // File 다운로드 체크 Data
export const SSVC_TYPE_FILE_INFO_RES = 4; // File 정보 전송 응답
export const SSVC_TYPE_FILE_DOWN_CHECK_REQ = 11; // File 다운로드 완료 요청
export const SSVC_TYPE_FILE_DOWN_CHECK_RES = 12; // File 다운로드 완료 응답

export const decodeInfoCheckData: ProtocolDecoder<InfoCheckData> = (
  message: ProtocolMessage
) => {
  const fileDownloadInfos: FileDownloadInfo[] = [];
  message.bodyList.forEach(fileInfo => {
    const info = fileInfo.split(BodyStringDivider);
    fileDownloadInfos.push({
      roomSeq: info[0],
      seq: Number(info[1]),
      userSeq: Number(info[2]),
      userName: info[3],
      downloadDate: info[4],
      isDownload: info[5] === 'Y' ? true : false
    });
  });

  return decodeProtocolMessage(message, {
    fileDownloadInfos
  } as InfoCheckData);
};