2019-09-24 18:21:22 +09:00
|
|
|
import { LocaleCode } from '@ucap-webmessenger/core';
|
|
|
|
import {
|
|
|
|
ProtocolRequest,
|
|
|
|
ProtocolResponse,
|
|
|
|
ProtocolEncoder,
|
|
|
|
PacketBody,
|
|
|
|
PacketBodyValue,
|
|
|
|
ProtocolDecoder,
|
|
|
|
ProtocolMessage,
|
|
|
|
BodyStringDivider
|
|
|
|
} from '@ucap-webmessenger/protocol';
|
|
|
|
import {
|
|
|
|
RoomInfo,
|
|
|
|
UserInfoShort,
|
|
|
|
UserInfo,
|
|
|
|
EmployeeType
|
|
|
|
} from '@ucap-webmessenger/protocol-room';
|
|
|
|
import { RoleCode } from '@ucap-webmessenger/protocol-authentication';
|
|
|
|
import { EventType } from '@ucap-webmessenger/protocol-event';
|
|
|
|
|
|
|
|
export interface SyncRoomRequest extends ProtocolRequest {
|
|
|
|
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
|
|
|
|
syncDate: string;
|
|
|
|
// 언어코드
|
|
|
|
localeCode: LocaleCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SyncRoomDataResponse extends ProtocolResponse {
|
|
|
|
// n. {대화방정보}...
|
|
|
|
roomInfos: RoomInfo[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SyncRoomUserDataResponse extends ProtocolResponse {
|
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1n. {참여자정보}
|
|
|
|
userInfos: UserInfoShort[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SyncRoomUserDataDetailResponse extends ProtocolResponse {
|
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1n. {참여자정보-D}
|
|
|
|
userInfos: UserInfo[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SyncRoomResponse extends ProtocolResponse {
|
|
|
|
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
|
|
|
|
syncDate: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const encodeSyncRoom: ProtocolEncoder<SyncRoomRequest> = (
|
|
|
|
req: SyncRoomRequest
|
|
|
|
) => {
|
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' });
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.localeCode });
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeSyncRoom: ProtocolDecoder<SyncRoomResponse> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
syncDate: message.bodyList[0]
|
|
|
|
} as SyncRoomResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeSyncRoomData: ProtocolDecoder<SyncRoomDataResponse> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
const roomInfos: RoomInfo[] = [];
|
|
|
|
if (message.bodyList.length > 1) {
|
|
|
|
const info = message.bodyList[1].split(BodyStringDivider);
|
|
|
|
if (info.length > 11) {
|
|
|
|
roomInfos.push({
|
|
|
|
roomSeq: info[0],
|
|
|
|
roomType: info[1],
|
|
|
|
roomName: info[2],
|
|
|
|
finalEventType: info[3] as EventType,
|
|
|
|
finalEventMessage: info[4],
|
|
|
|
finalEventDate: info[5],
|
|
|
|
joinUserCount: info[6],
|
|
|
|
noReadCnt: info[7],
|
|
|
|
isAlarm: info[8] !== 'N' ? true : false,
|
|
|
|
isJoinRoom: info[9] === 'Y' ? true : false,
|
|
|
|
expiredFileStdSeq: info[10],
|
|
|
|
isTimeRoom: info[11] === 'Y' ? true : false,
|
|
|
|
timeRoomInterval: info[11] !== 'Y' ? 0 : info[12] || 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
roomInfos
|
|
|
|
} as SyncRoomDataResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeSyncRoomUserData: ProtocolDecoder<
|
|
|
|
SyncRoomUserDataResponse
|
|
|
|
> = (message: ProtocolMessage) => {
|
|
|
|
const userInfos: UserInfoShort[] = [];
|
|
|
|
message.bodyList.slice(1).forEach(userInfo => {
|
|
|
|
const info = userInfo.split(BodyStringDivider);
|
|
|
|
userInfos.push({
|
2019-09-25 09:32:56 +09:00
|
|
|
seq: info[0],
|
2019-09-24 18:21:22 +09:00
|
|
|
name: info[1],
|
|
|
|
profileImageFile: info[2],
|
|
|
|
isJoinRoom: info[3],
|
|
|
|
lastReadEventSeq: info[4],
|
|
|
|
madn: info[5],
|
|
|
|
hardSadn: info[6],
|
|
|
|
fmcSadn: info[7],
|
|
|
|
nameEn: info[8],
|
|
|
|
nameCn: info[9],
|
|
|
|
isPrivacyAgree: info[10] === 'Y' ? true : false,
|
|
|
|
isValidLogin: info[11] === 'Y' ? true : false,
|
|
|
|
employeeType: info[12] as EmployeeType,
|
|
|
|
fontColor: info[13]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
userInfos
|
|
|
|
} as SyncRoomUserDataResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeSyncRoomUserDataDetail: ProtocolDecoder<
|
|
|
|
SyncRoomUserDataDetailResponse
|
|
|
|
> = (message: ProtocolMessage) => {
|
|
|
|
const userInfos: UserInfo[] = [];
|
|
|
|
message.bodyList.slice(1).forEach(userInfo => {
|
|
|
|
const info = userInfo.split(BodyStringDivider);
|
|
|
|
userInfos.push({
|
2019-09-25 09:32:56 +09:00
|
|
|
seq: info[0],
|
2019-09-24 18:21:22 +09:00
|
|
|
name: info[1],
|
|
|
|
profileImageFile: info[2],
|
|
|
|
grade: info[3],
|
|
|
|
intro: info[4],
|
|
|
|
companyCode: info[5],
|
|
|
|
hpNumber: info[6],
|
|
|
|
lineNumber: info[7],
|
|
|
|
email: info[8],
|
|
|
|
isMobile: info[9] === 'Y' ? true : false,
|
|
|
|
deptName: info[10],
|
|
|
|
isJoinRoom: info[11] === 'Y' ? true : false,
|
|
|
|
lastReadEventSeq: info[12],
|
|
|
|
isActive: info[13] === 'Y' ? true : false,
|
|
|
|
roleCd: info[14] as RoleCode,
|
|
|
|
employeeNum: info[15],
|
|
|
|
madn: info[16],
|
|
|
|
hardSadn: info[17],
|
|
|
|
fmcSadn: info[18],
|
|
|
|
nameEn: info[19],
|
|
|
|
nameCn: info[20],
|
|
|
|
gradeEn: info[21],
|
|
|
|
gradeCn: info[22],
|
|
|
|
deptNameEn: info[23],
|
|
|
|
deptNameCn: info[24],
|
|
|
|
callMode: info[25],
|
|
|
|
isPrivacyAgree: info[26] === 'Y' ? true : false,
|
|
|
|
isValidLogin: info[27] === 'Y' ? true : false,
|
|
|
|
employeeType: info[28] as EmployeeType,
|
|
|
|
id: info[29]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
userInfos
|
|
|
|
} as SyncRoomUserDataDetailResponse;
|
|
|
|
};
|