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';
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export interface RoomRequest extends ProtocolRequest {
|
2019-09-24 18:21:22 +09:00
|
|
|
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
|
|
|
|
syncDate: string;
|
|
|
|
// 언어코드
|
|
|
|
localeCode: LocaleCode;
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export interface RoomDataResponse extends ProtocolResponse {
|
2019-09-24 18:21:22 +09:00
|
|
|
// n. {대화방정보}...
|
|
|
|
roomInfos: RoomInfo[];
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export interface RoomUserDataResponse extends ProtocolResponse {
|
2019-09-24 18:21:22 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1n. {참여자정보}
|
|
|
|
userInfos: UserInfoShort[];
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export interface RoomUserDataDetailResponse extends ProtocolResponse {
|
2019-09-24 18:21:22 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1n. {참여자정보-D}
|
|
|
|
userInfos: UserInfo[];
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export interface RoomResponse extends ProtocolResponse {
|
2019-09-24 18:21:22 +09:00
|
|
|
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
|
|
|
|
syncDate: string;
|
|
|
|
}
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export const encodeRoom: ProtocolEncoder<RoomRequest> = (req: RoomRequest) => {
|
2019-09-24 18:21:22 +09:00
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' });
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.localeCode });
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export const decodeRoom: ProtocolDecoder<RoomResponse> = (
|
2019-09-24 18:21:22 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
syncDate: message.bodyList[0]
|
2019-09-25 14:48:36 +09:00
|
|
|
} as RoomResponse;
|
2019-09-24 18:21:22 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export const decodeRoomData: ProtocolDecoder<RoomDataResponse> = (
|
2019-09-24 18:21:22 +09:00
|
|
|
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
|
2019-09-25 14:48:36 +09:00
|
|
|
} as RoomDataResponse;
|
2019-09-24 18:21:22 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
2019-09-24 18:21:22 +09:00
|
|
|
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
|
2019-09-25 14:48:36 +09:00
|
|
|
} as RoomUserDataResponse;
|
2019-09-24 18:21:22 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 14:48:36 +09:00
|
|
|
export const decodeRoomUserDataDetail: ProtocolDecoder<
|
|
|
|
RoomUserDataDetailResponse
|
2019-09-24 18:21:22 +09:00
|
|
|
> = (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
|
2019-09-25 14:48:36 +09:00
|
|
|
} as RoomUserDataDetailResponse;
|
2019-09-24 18:21:22 +09:00
|
|
|
};
|