2019-09-23 17:00:05 +09:00
|
|
|
import {
|
|
|
|
ProtocolRequest,
|
|
|
|
ProtocolResponse,
|
|
|
|
ProtocolEncoder,
|
|
|
|
PacketBody,
|
|
|
|
PacketBodyValue,
|
|
|
|
ProtocolDecoder,
|
|
|
|
ProtocolMessage,
|
2019-09-25 16:13:33 +09:00
|
|
|
BodyStringDivider,
|
|
|
|
ProtocolStream
|
2019-09-23 17:00:05 +09:00
|
|
|
} from '@ucap-webmessenger/protocol';
|
|
|
|
import { LocaleCode } from '@ucap-webmessenger/core';
|
|
|
|
import { RoomType } from '../types/room.type';
|
2019-09-24 18:21:22 +09:00
|
|
|
import { EventType } from '@ucap-webmessenger/protocol-event';
|
2019-09-23 17:00:05 +09:00
|
|
|
import { EmployeeType } from '../types/employee.type';
|
|
|
|
import { RoleCode } from '@ucap-webmessenger/protocol-authentication';
|
|
|
|
|
|
|
|
export interface RoomInfo {
|
|
|
|
// 0. 대화방SEQ
|
|
|
|
roomSeq: string;
|
|
|
|
// 1. 대화방종류
|
|
|
|
roomType: RoomType;
|
|
|
|
// 2. 대화방명
|
|
|
|
roomName: string;
|
|
|
|
// 3. 최종타입
|
|
|
|
finalEventType: EventType;
|
|
|
|
// 4. 최종대화
|
|
|
|
finalEventMessage: string;
|
|
|
|
// 5. 최종시간
|
|
|
|
finalEventDate: string;
|
|
|
|
// 6. 참여인원수
|
|
|
|
joinUserCount: number;
|
|
|
|
// 7. 안읽은수
|
|
|
|
noReadCnt: number;
|
|
|
|
// 8. 알람여부
|
|
|
|
isAlarm: boolean;
|
|
|
|
// 9. 참여여부
|
|
|
|
isJoinRoom: boolean;
|
|
|
|
// 10. 유효한파일 이벤트 기준 SEQ
|
|
|
|
expiredFileStdSeq: number;
|
|
|
|
// 11. 타이머대화방여부YN
|
|
|
|
isTimeRoom: boolean;
|
|
|
|
// 12. 타이머시간(n)
|
|
|
|
timeRoomInterval: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UserInfoShort {
|
|
|
|
// 0. 사용자SEQ
|
2019-09-25 09:32:56 +09:00
|
|
|
seq: number;
|
2019-09-23 17:00:05 +09:00
|
|
|
// 1. 사용자명
|
|
|
|
name: string;
|
|
|
|
// 2. 사진파일
|
|
|
|
profileImageFile: string;
|
|
|
|
// 3. 참여여부
|
|
|
|
isJoinRoom: boolean;
|
|
|
|
// 4. 최종확인SEQ
|
|
|
|
lastReadEventSeq: number;
|
|
|
|
// 5. MADN
|
|
|
|
madn: string;
|
|
|
|
// 6. HARDPHONE_SADN
|
|
|
|
hardSadn: string;
|
|
|
|
// 7. FMC_SADN
|
|
|
|
fmcSadn: string;
|
|
|
|
// 8. 사용자명(영어)
|
|
|
|
nameEn: string;
|
|
|
|
// 9. 사용자명(중국어)
|
|
|
|
nameCn: string;
|
|
|
|
// 10. 이용약관동의여부YN
|
|
|
|
isPrivacyAgree: boolean;
|
|
|
|
// 11. 유효접속여부YN
|
|
|
|
isValidLogin: boolean;
|
|
|
|
// 12. 임직원유형(s)
|
|
|
|
employeeType: EmployeeType;
|
|
|
|
// 13. 폰트색(s)
|
|
|
|
fontColor: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UserInfo {
|
|
|
|
// 0. 사용자SEQ
|
2019-09-25 09:32:56 +09:00
|
|
|
seq: number;
|
2019-09-23 17:00:05 +09:00
|
|
|
// 1. 사용자명
|
|
|
|
name: string;
|
|
|
|
// 2. 사진파일
|
|
|
|
profileImageFile: string;
|
|
|
|
// 3. 직급
|
|
|
|
grade: string;
|
|
|
|
// 4. 업무소개
|
|
|
|
intro: string;
|
|
|
|
// 5. 기관코드
|
|
|
|
companyCode: string;
|
|
|
|
// 6. 핸드폰번호
|
|
|
|
hpNumber: string;
|
|
|
|
// 7. 내선번호
|
|
|
|
lineNumber: string;
|
|
|
|
// 8. 이메일
|
|
|
|
email: string;
|
|
|
|
// 9. 모바일YN
|
|
|
|
isMobile: boolean;
|
|
|
|
// 10. 부서명
|
|
|
|
deptName: string;
|
2019-09-24 18:21:22 +09:00
|
|
|
// 11. 참여 여부 <<<<
|
2019-09-23 17:00:05 +09:00
|
|
|
isJoinRoom: boolean;
|
2019-09-24 18:21:22 +09:00
|
|
|
// 12. 최종확인SEQ <<<<
|
2019-09-23 17:00:05 +09:00
|
|
|
lastReadEventSeq: number;
|
|
|
|
// 13. ActiveYN
|
|
|
|
isActive: boolean;
|
|
|
|
// 14. 역할코드
|
|
|
|
roleCd: RoleCode;
|
|
|
|
// 15. 사번
|
|
|
|
employeeNum: string;
|
|
|
|
// 16. MADN
|
|
|
|
madn: string;
|
|
|
|
// 17. HARDPHONE_SADN
|
|
|
|
hardSadn: string;
|
|
|
|
// 18. FMC_SADN
|
|
|
|
fmcSadn: string;
|
|
|
|
// 19. 사용자명(영어)
|
|
|
|
nameEn: string;
|
|
|
|
// 20. 사용자명(중국어)
|
|
|
|
nameCn: string;
|
|
|
|
// 21. 직급(영어)
|
|
|
|
gradeEn: string;
|
|
|
|
// 22. 직급(중국어)
|
|
|
|
gradeCn: string;
|
|
|
|
// 23. 부서명(영어)
|
|
|
|
deptNameEn: string;
|
|
|
|
// 24. 부서명(중국어)
|
|
|
|
deptNameCn: string;
|
2019-09-24 18:21:22 +09:00
|
|
|
// 25. CALL_MODE <<<
|
2019-09-23 17:00:05 +09:00
|
|
|
callMode: string;
|
|
|
|
// 26. 이용약관동의여부YN
|
|
|
|
isPrivacyAgree: boolean;
|
|
|
|
// 27. 유효접속여부YN
|
|
|
|
isValidLogin: boolean;
|
|
|
|
// 28. 임직원유형(s)
|
|
|
|
employeeType: EmployeeType;
|
2019-09-24 18:21:22 +09:00
|
|
|
// 29. 사용자아이디(s) <<<
|
2019-09-23 17:00:05 +09:00
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface InfoRequest extends ProtocolRequest {
|
2019-09-23 17:00:05 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1. 상세정보여부(y)
|
|
|
|
isDetail: boolean;
|
|
|
|
// 2. 언어코드(s)
|
|
|
|
localeCode: LocaleCode;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface InfoResponse extends ProtocolResponse {
|
2019-09-23 17:00:05 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface InfoData extends ProtocolStream {
|
2019-09-23 17:00:05 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1. {대화방정보}
|
|
|
|
roomInfo: RoomInfo;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UserShortData extends ProtocolStream {
|
2019-09-23 17:00:05 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 1n. {참여자정보}
|
|
|
|
userInfos: UserInfoShort[];
|
|
|
|
}
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UserData extends ProtocolStream {
|
2019-09-23 17:00:05 +09:00
|
|
|
// 0. 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
2019-09-24 18:21:22 +09:00
|
|
|
// 1n. {참여자정보-D}
|
2019-09-23 17:00:05 +09:00
|
|
|
userInfos: UserInfo[];
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const encodeInfo: ProtocolEncoder<InfoRequest> = (req: InfoRequest) => {
|
2019-09-23 17:00:05 +09:00
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
|
|
|
|
bodyList.push({
|
|
|
|
type: PacketBodyValue.String,
|
|
|
|
value: req.isDetail !== true ? 'N' : 'Y'
|
|
|
|
}); // 요청응답을 상세로 받는것을 default
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.localeCode });
|
|
|
|
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeInfo: ProtocolDecoder<InfoResponse> = (
|
2019-09-23 17:00:05 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0]
|
2019-09-25 16:13:33 +09:00
|
|
|
} as InfoResponse;
|
2019-09-23 17:00:05 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeInfoData: ProtocolDecoder<InfoData> = (
|
2019-09-23 17:00:05 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
let roomInfo: RoomInfo = null;
|
|
|
|
if (message.bodyList.length > 1) {
|
|
|
|
const info = message.bodyList[1].split(BodyStringDivider);
|
|
|
|
if (info.length > 11) {
|
|
|
|
roomInfo = {
|
|
|
|
roomSeq: info[0],
|
2019-09-25 13:21:07 +09:00
|
|
|
roomType: info[1] as RoomType,
|
2019-09-23 17:00:05 +09:00
|
|
|
roomName: info[2],
|
|
|
|
finalEventType: info[3] as EventType,
|
|
|
|
finalEventMessage: info[4],
|
|
|
|
finalEventDate: info[5],
|
2019-09-27 12:51:57 +09:00
|
|
|
joinUserCount: Number(info[6]),
|
|
|
|
noReadCnt: Number(info[7]),
|
2019-09-23 17:00:05 +09:00
|
|
|
isAlarm: info[8] !== 'N' ? true : false,
|
|
|
|
isJoinRoom: info[9] === 'Y' ? true : false,
|
2019-09-27 12:51:57 +09:00
|
|
|
expiredFileStdSeq: Number(info[10]),
|
2019-09-23 17:00:05 +09:00
|
|
|
isTimeRoom: info[11] === 'Y' ? true : false,
|
2019-09-27 12:51:57 +09:00
|
|
|
timeRoomInterval: info[11] !== 'Y' ? 0 : Number(info[12]) || 0
|
2019-09-23 17:00:05 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
roomInfo
|
2019-09-25 16:13:33 +09:00
|
|
|
} as InfoData;
|
2019-09-23 17:00:05 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUserShortData: ProtocolDecoder<UserShortData> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
2019-09-23 17:00:05 +09:00
|
|
|
const userInfos: UserInfoShort[] = [];
|
|
|
|
message.bodyList.slice(1).forEach(userInfo => {
|
|
|
|
const info = userInfo.split(BodyStringDivider);
|
|
|
|
userInfos.push({
|
2019-09-27 12:51:57 +09:00
|
|
|
seq: Number(info[0]),
|
2019-09-23 17:00:05 +09:00
|
|
|
name: info[1],
|
|
|
|
profileImageFile: info[2],
|
|
|
|
isJoinRoom: info[3],
|
2019-09-27 12:51:57 +09:00
|
|
|
lastReadEventSeq: Number(info[4]),
|
2019-09-23 17:00:05 +09:00
|
|
|
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 16:13:33 +09:00
|
|
|
} as UserShortData;
|
2019-09-23 17:00:05 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUserData: ProtocolDecoder<UserData> = (
|
2019-09-23 17:00:05 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
const userInfos: UserInfo[] = [];
|
|
|
|
message.bodyList.slice(1).forEach(userInfo => {
|
|
|
|
const info = userInfo.split(BodyStringDivider);
|
|
|
|
userInfos.push({
|
2019-09-27 12:51:57 +09:00
|
|
|
seq: Number(info[0]),
|
2019-09-23 17:00:05 +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 16:13:33 +09:00
|
|
|
} as UserData;
|
2019-09-23 17:00:05 +09:00
|
|
|
};
|
2019-09-25 13:21:07 +09:00
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UserStatusOfflineRequest extends ProtocolRequest {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UserStatusOfflineResponse extends ProtocolResponse {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 사용자SEQ(n)...
|
|
|
|
userSeqs: number[];
|
|
|
|
}
|
2019-09-25 16:13:33 +09:00
|
|
|
export const encodeUserStatusOffline: ProtocolEncoder<
|
|
|
|
UserStatusOfflineRequest
|
|
|
|
> = (req: UserStatusOfflineRequest) => {
|
2019-09-25 13:21:07 +09:00
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
|
|
|
|
return bodyList;
|
|
|
|
};
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUserStatusOffline: ProtocolDecoder<
|
|
|
|
UserStatusOfflineResponse
|
2019-09-25 13:21:07 +09:00
|
|
|
> = (message: ProtocolMessage) => {
|
|
|
|
let userSeqs: number[] = [];
|
|
|
|
if (message.bodyList.length > 1) {
|
|
|
|
userSeqs = message.bodyList.slice(1);
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
userSeqs
|
2019-09-25 16:13:33 +09:00
|
|
|
} as UserStatusOfflineResponse;
|
2019-09-25 13:21:07 +09:00
|
|
|
};
|