import { StatusCode, JsonAnalization } from '@ucap-webmessenger/api'; import { FileType } from '@ucap-webmessenger/protocol-file'; import { EventJsonDecoder } from './event-json'; export interface FileEventJson { statusCode?: StatusCode; errorMessage?: string; roomSeq?: number; fileName?: string; fileExt?: string; fileType?: FileType; thumbUrl?: string; attachmentSeq?: number; attachmentSize?: number; attachmentRegDate?: string; imageWidth?: number; imageHeight?: number; companyCode?: string; voiceTime?: string; synappKey?: string; } export const decodeFileEventJson: EventJsonDecoder = ( message: string ) => { try { const json = JsonAnalization.receiveAnalization(message); return { statusCode: json.StatusCode, errorMessage: json.ErrorMessage, roomSeq: Number(json.RoomID), fileName: json.FileName, fileExt: json.FileExt, fileType: json.FileType, thumbUrl: json.ThumbURL, attachmentSeq: Number(json.AttSEQ), attachmentSize: Number(json.AttSize), attachmentRegDate: json.AttRegDate, imageWidth: Number(json.ImageWidth), imageHeight: Number(json.ImageHeight), companyCode: json.CompanyCode, voiceTime: json.VoiceTime, synappKey: json.SynappKey } as FileEventJson; } catch (e) { return { statusCode: StatusCode.Fail, errorMessage: e.toString() } as FileEventJson; } };