diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/models/down-check.ts b/projects/ucap-webmessenger-protocol-file/src/lib/models/down-check.ts new file mode 100644 index 00000000..30aa938a --- /dev/null +++ b/projects/ucap-webmessenger-protocol-file/src/lib/models/down-check.ts @@ -0,0 +1,37 @@ +import { LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface DownCheckRequest extends ProtocolRequest { + // 파일SEQ + seq: number; +} + +export interface DownCheckResponse extends ProtocolResponse { + // 파일SEQ + seq: number; +} + +export const encodeDownCheck: ProtocolEncoder = ( + req: DownCheckRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.Integer, value: req.seq }); + return bodyList; +}; + +export const decodeDownCheck: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + seq: message.bodyList[0] + } as DownCheckResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/models/info.ts b/projects/ucap-webmessenger-protocol-file/src/lib/models/info.ts new file mode 100644 index 00000000..0923ec9d --- /dev/null +++ b/projects/ucap-webmessenger-protocol-file/src/lib/models/info.ts @@ -0,0 +1,144 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { FileType } from '../types/file.type'; + +export interface InfoRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // { 파일타입 } cf) I : 이미지 V: 동영상 F: 파일 "" 빈값이면 모든 타입을 내려줌 + type: FileType; +} + +export interface FileInfo { + // 대화방SEQ + roomSeq: string; + // 이벤트SEQ + eventSeq: number; + // 파일SEQ + seq: number; + // 송신자SEQ + senderSeq: number; + // 파일타입 + type: FileType; + // 파일이름 + name: string; + // 파일URL + url: string; + // 파일크기(byte) + size: number; + // 전송일시 + sendDate: string; + // 수신완료자수 + receivedUserCount: number; + // 수신자수 + receiverCount: number; +} + +export interface InfoData extends ProtocolStream { + // { 대화방파일정보 }... + fileInfos: FileInfo[]; +} + +export interface FileDownloadInfo { + // 대화방SEQ + roomSeq: string; + // 파일SEQ + seq: number; + // 사용자SEQ + userSeq: number; + // 사용자명 + userName: string; + // 다운로드일시 + downloadDate: string; + // DownYN + isDownload: boolean; +} + +export interface InfoCheckData extends ProtocolStream { + // { 파일다운로드정보 }... + fileDownloadInfos: FileDownloadInfo[]; +} + +export interface InfoResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // { 파일타입 } cf) I : 이미지 V: 동영상 F: 파일 "" 빈값이면 모든 타입을 내려줌 + type: FileType; +} + +export const encodeInfo: ProtocolEncoder = (req: InfoRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.String, value: req.type } + ); + return bodyList; +}; + +export const decodeInfoData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const fileInfos: FileInfo[] = []; + message.bodyList.forEach(fileInfo => { + const info = fileInfo.split(BodyStringDivider); + let i = 0; + fileInfos.push({ + roomSeq: info[i], + eventSeq: Number(info[i++]), + seq: Number(info[i++]), + senderSeq: Number(info[i++]), + type: info[i++] as FileType, + name: info[i++], + url: info[i++], + size: info[i++], + sendDate: info[i++], + receivedUserCount: Number(info[i++]), + receiverCount: Number(info[i++]) + }); + }); + + return { + fileInfos + } as InfoData; +}; + +export const decodeInfoCheckData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const fileDownloadInfos: FileDownloadInfo[] = []; + message.bodyList.forEach(fileInfo => { + const info = fileInfo.split(BodyStringDivider); + let i = 0; + fileDownloadInfos.push({ + roomSeq: info[i], + seq: Number(info[i++]), + userSeq: Number(info[i++]), + userName: info[i++], + downloadDate: info[i++], + isDownload: info[i++] === 'Y' ? true : false + }); + }); + + return { + fileDownloadInfos + } as InfoCheckData; +}; + +export const decodeInfo: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + type: message.bodyList[1] as FileType + } as InfoResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/services/file-protocol.service.ts b/projects/ucap-webmessenger-protocol-file/src/lib/services/file-protocol.service.ts index 88b90029..a0c277eb 100644 --- a/projects/ucap-webmessenger-protocol-file/src/lib/services/file-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-file/src/lib/services/file-protocol.service.ts @@ -1,8 +1,79 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, takeWhile, take } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + SSVC_TYPE_FILE_INFO_REQ, + SVC_TYPE_FILE, + SSVC_TYPE_FILE_INFO_RES, + SSVC_TYPE_FILE_INFO_DATA, + SSVC_TYPE_FILE_INFO_CHECK_DATA, + SSVC_TYPE_FILE_DOWN_CHECK_REQ +} from '../types/service'; +import { + InfoRequest, + InfoResponse, + encodeInfo, + decodeInfo, + InfoData, + InfoCheckData, + decodeInfoData, + decodeInfoCheckData +} from '../models/info'; +import { + DownCheckRequest, + DownCheckResponse, + encodeDownCheck, + decodeDownCheck +} from '../models/down-check'; @Injectable({ providedIn: 'root' }) export class FileProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public info( + req: InfoRequest + ): Observable { + return this.protocolService + .call(SVC_TYPE_FILE, SSVC_TYPE_FILE_INFO_REQ, ...encodeInfo(req)) + .pipe( + takeWhile(res => SSVC_TYPE_FILE_INFO_RES !== res.subServiceType, true), + map(res => { + if (SSVC_TYPE_FILE_INFO_DATA === res.subServiceType) { + return { + ...decodeInfoData(res), + Type: SSVC_TYPE_FILE_INFO_DATA + }; + } else if (SSVC_TYPE_FILE_INFO_CHECK_DATA === res.subServiceType) { + return { + ...decodeInfoCheckData(res), + Type: SSVC_TYPE_FILE_INFO_CHECK_DATA + }; + } + + return { + ...decodeInfo(res), + Type: SSVC_TYPE_FILE_INFO_RES + }; + }) + ); + } + + public downCheck(req: DownCheckRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_FILE, + SSVC_TYPE_FILE_DOWN_CHECK_REQ, + ...encodeDownCheck(req) + ) + .pipe( + take(1), + map(res => { + return decodeDownCheck(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/types/file.type.ts b/projects/ucap-webmessenger-protocol-file/src/lib/types/file.type.ts new file mode 100644 index 00000000..9d244882 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-file/src/lib/types/file.type.ts @@ -0,0 +1,10 @@ +export enum FileType { + // I : 이미지 + Image = 'I', + // V : 동영상 + Video = 'V', + // F : 파일 + File = 'F', + // "" 빈값이면 모든 타입을 내려줌 + All = '' +} diff --git a/projects/ucap-webmessenger-protocol-file/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-file/src/lib/types/service.ts new file mode 100644 index 00000000..10afeb2e --- /dev/null +++ b/projects/ucap-webmessenger-protocol-file/src/lib/types/service.ts @@ -0,0 +1,7 @@ +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 다운로드 완료 응답 diff --git a/projects/ucap-webmessenger-protocol-file/src/public-api.ts b/projects/ucap-webmessenger-protocol-file/src/public-api.ts index 1b7dc0be..b8b41e1b 100644 --- a/projects/ucap-webmessenger-protocol-file/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-file/src/public-api.ts @@ -2,6 +2,12 @@ * Public API Surface of ucap-webmessenger-protocol-file */ +export * from './lib/models/down-check'; +export * from './lib/models/info'; + export * from './lib/services/file-protocol.service'; +export * from './lib/types/file.type'; +export * from './lib/types/service'; + export * from './lib/ucap-file-protocol.module'; diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/models/status.ts b/projects/ucap-webmessenger-protocol-info/src/lib/models/status.ts new file mode 100644 index 00000000..ab3c5364 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-info/src/lib/models/status.ts @@ -0,0 +1,58 @@ +import { DeviceType, LocaleCode, StatusCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + ProtocolNotification, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; +import { UserInfoUpdateType } from '../types/user-info-update.type'; +import { StatusInfo } from '@ucap-webmessenger/protocol-status'; + +export interface StatusRequest extends ProtocolRequest { + // 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface StatusResponse extends ProtocolResponse { + // {상태정보}... + statusInfos: StatusInfo[]; +} + +export const encodeStatus: ProtocolEncoder = ( + req: StatusRequest +) => { + const bodyList: PacketBody[] = []; + + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + return bodyList; +}; + +export const decodeStatus: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const statusInfos: StatusInfo[] = []; + message.bodyList.forEach(statusInfo => { + const info = statusInfo.split(BodyStringDivider); + let idx = 0; + statusInfos.push({ + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode + }); + }); + return { + statusInfos + } as StatusResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/models/user-option.ts b/projects/ucap-webmessenger-protocol-info/src/lib/models/user-option.ts new file mode 100644 index 00000000..96f1d82e --- /dev/null +++ b/projects/ucap-webmessenger-protocol-info/src/lib/models/user-option.ts @@ -0,0 +1,50 @@ +import { DeviceType, LocaleCode, CallerType } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; +import { UserInfoUpdateType } from '../types/user-info-update.type'; + +export interface UserOptionResponse extends ProtocolResponse { + // 타입(s) + type: CallerType; +} + +export const decodeUserOption: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { type: message.bodyList[0] as CallerType } as UserOptionResponse; +}; + +export interface UserOptionUpdateRequest extends ProtocolRequest { + // 타입(s) + type: CallerType; +} + +export interface UserOptionUpdateResponse extends ProtocolResponse { + // 타입(s) + type: CallerType; +} + +export const encodeUserOptionUpdate: ProtocolEncoder< + UserOptionUpdateRequest +> = (req: UserOptionUpdateRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.type }); + return bodyList; +}; + +export const decodeUserOptionUpdate: ProtocolDecoder< + UserOptionUpdateResponse +> = (message: ProtocolMessage) => { + return { + type: message.bodyList[0] as CallerType + } as UserOptionUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/models/user.ts b/projects/ucap-webmessenger-protocol-info/src/lib/models/user.ts new file mode 100644 index 00000000..ac6e9974 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-info/src/lib/models/user.ts @@ -0,0 +1,62 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; +import { UserInfoUpdateType } from '../types/user-info-update.type'; + +export interface UserRequest extends ProtocolRequest { + // 타입(s) + type: UserInfoUpdateType; + // 정보(s) + info: string; +} + +export interface UserResponse extends ProtocolResponse { + // 타입(s) + type: UserInfoUpdateType; + // 정보(s) + info: string; +} + +export interface UserNotification extends ProtocolNotification { + // 타입(s) + type: UserInfoUpdateType; + // 정보(s) + info: string; +} + +export const encodeUser: ProtocolEncoder = (req: UserRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.type }, + { type: PacketBodyValue.String, value: req.info } + ); + + return bodyList; +}; + +export const decodeUser: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + type: message.bodyList[0] as UserInfoUpdateType, + info: message.bodyList[1] + } as UserResponse; +}; + +export const decodeUserNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + type: message.bodyList[0] as UserInfoUpdateType, + info: message.bodyList[1] + } as UserNotification; +}; diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/services/info-protocol.service.ts b/projects/ucap-webmessenger-protocol-info/src/lib/services/info-protocol.service.ts index 60575e70..11ef17d9 100644 --- a/projects/ucap-webmessenger-protocol-info/src/lib/services/info-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-info/src/lib/services/info-protocol.service.ts @@ -1,8 +1,82 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + SVC_TYPE_INFO, + SSVC_TYPE_INFO_USER_REQ, + SSVC_TYPE_INFO_STATE_REQ, + SSVC_TYPE_INFO_USER_OPTION_REQ, + SSVC_TYPE_INFO_USER_OPTION_UPD_REQ +} from '../types/service'; +import { + UserRequest, + encodeUser, + UserResponse, + decodeUser +} from '../models/user'; +import { + StatusRequest, + StatusResponse, + encodeStatus, + decodeStatus +} from '../models/status'; +import { + UserOptionResponse, + decodeUserOption, + UserOptionUpdateRequest, + encodeUserOptionUpdate, + UserOptionUpdateResponse, + decodeUserOptionUpdate +} from '../models/user-option'; + @Injectable({ providedIn: 'root' }) export class InfoProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public user(req: UserRequest): Observable { + return this.protocolService + .call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_REQ, ...encodeUser(req)) + .pipe( + take(1), + map(res => decodeUser(res)) + ); + } + + public status(req: StatusRequest): Observable { + return this.protocolService + .call(SVC_TYPE_INFO, SSVC_TYPE_INFO_STATE_REQ, ...encodeStatus(req)) + .pipe( + take(1), + map(res => decodeStatus(res)) + ); + } + + public userOption(): Observable { + return this.protocolService + .call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_OPTION_REQ) + .pipe( + take(1), + map(res => decodeUserOption(res)) + ); + } + + public userOptionUpdate( + req: UserOptionUpdateRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_INFO, + SSVC_TYPE_INFO_USER_OPTION_UPD_REQ, + ...encodeUserOptionUpdate(req) + ) + .pipe( + take(1), + map(res => decodeUserOptionUpdate(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-info/src/lib/types/service.ts new file mode 100644 index 00000000..1f0841ba --- /dev/null +++ b/projects/ucap-webmessenger-protocol-info/src/lib/types/service.ts @@ -0,0 +1,14 @@ +export const SVC_TYPE_INFO = 30; +export const SSVC_TYPE_INFO_USER_REQ = 1; // 사용자 정보 변경 요청 +export const SSVC_TYPE_INFO_USER_RES = 2; +export const SSVC_TYPE_INFO_USER_NOTI = 3; +export const SSVC_TYPE_INFO_STATE_REQ = 11; // 사용자 상태 정보 요청 +export const SSVC_TYPE_INFO_STATE_RES = 13; // 사용자 상태 정보 응답 +export const SSVC_TYPE_INFO_USER_OPTION_REQ = 21; // 사용자 환경 정보 요청 +export const SSVC_TYPE_INFO_USER_OPTION_RES = 22; // 사용자 환경 정보 응답 +export const SSVC_TYPE_INFO_USER_OPTION_UPD_REQ = 23; // 사용자 환경 정보 변경 요청 +export const SSVC_TYPE_INFO_USER_OPTION_UPD_RES = 24; // 사용자 환경 정보 변경 응답 +export const SSVC_TYPE_INFO_QUERY_SESSION_REQ = 41; // 세션 정보 요청 +export const SSVC_TYPE_INFO_QUERY_SESSION_RES = 42; // 세션 정보 응답 +export const SSVC_TYPE_INFO_BUDDY_NICKNAME_REQ = 51; // 동료 닉네임 변경 요청 +export const SSVC_TYPE_INFO_BUDDY_NICKNAME_RES = 52; // 동료 닉네임 변경 응답 diff --git a/projects/ucap-webmessenger-protocol-info/src/lib/types/user-info-update.type.ts b/projects/ucap-webmessenger-protocol-info/src/lib/types/user-info-update.type.ts new file mode 100644 index 00000000..a2496524 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-info/src/lib/types/user-info-update.type.ts @@ -0,0 +1,13 @@ +export enum UserInfoUpdateType { + // I: 프로필 이미지 + Image = 'I', + // R: 인트로소개 + Intro = 'R', + // T: 전화보이기여부 + TelephoneVisible = 'T' +} + +export enum TelephoneVisibleType { + Show = 'Y', + Hide = 'N' +} diff --git a/projects/ucap-webmessenger-protocol-info/src/public-api.ts b/projects/ucap-webmessenger-protocol-info/src/public-api.ts index dbba1927..07f45e4c 100644 --- a/projects/ucap-webmessenger-protocol-info/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-info/src/public-api.ts @@ -2,6 +2,13 @@ * Public API Surface of ucap-webmessenger-protocol-info */ +export * from './lib/models/status'; +export * from './lib/models/user-option'; +export * from './lib/models/user'; + export * from './lib/services/info-protocol.service'; +export * from './lib/types/service'; +export * from './lib/types/user-info-update.type'; + export * from './lib/ucap-info-protocol.module'; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user-ext.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user-ext.ts new file mode 100644 index 00000000..efbc4731 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user-ext.ts @@ -0,0 +1,54 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; +import { CallMode } from '@ucap-webmessenger/core'; + +export interface DataUserExtRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 사용자SEQ(n) + seq: number; +} +export interface DataUserExtResponse extends ProtocolResponse { + // DivCD(s) + divCd: string; + // 사용자SEQ(n) + seq: number; + // CallMode(s) + callMode: CallMode; + // HARDPHONE_SADN + hardSadn: string; + // FMC_SADN + fmcSadn: string; +} + +export const encodeDataUserExt: ProtocolEncoder = ( + req: DataUserExtRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.divCd }, + { type: PacketBodyValue.Integer, value: req.seq } + ); + + return bodyList; +}; + +export const decodeDataUserExt: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + seq: message.bodyList[1], + callMode: message.bodyList[2] as CallMode, + hardSadn: message.bodyList[3], + fmcSadn: message.bodyList[4] + } as DataUserExtResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user.ts new file mode 100644 index 00000000..87216ce4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/data-user.ts @@ -0,0 +1,90 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; +import { EmployeeType } from '@ucap-webmessenger/protocol-room'; +import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; +import { UserInfoSS } from './dept-user'; + +export interface DataUserRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 사용자SEQ(n) + seq: number; + // 발신자회사코드(s) + senderCompanyCode: string; + // 발신자임직원유형(s) + senderEmployeeType: EmployeeType; +} +export interface DataUserResponse extends ProtocolResponse { + // DivCD(s) + divCd: string; + // {사용자정보-SS} + userInfo?: UserInfoSS; +} + +export const encodeDataUser: ProtocolEncoder = ( + req: DataUserRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.divCd }, + { type: PacketBodyValue.Integer, value: req.seq }, + { type: PacketBodyValue.String, value: req.senderCompanyCode }, + { type: PacketBodyValue.String, value: req.senderEmployeeType } + ); + + return bodyList; +}; + +export const decodeDataUser: ProtocolDecoder = ( + message: ProtocolMessage +) => { + let userInfo: UserInfoSS; + if (message.bodyList.length > 1) { + const info = message.bodyList[1].split(BodyStringDivider); + let i = 0; + userInfo = { + seq: Number(info[i]), + name: info[i++], + profileImageFile: info[i++], + grade: info[i++], + intro: info[i++], + companyCode: info[i++], + hpNumber: info[i++], + lineNumber: info[i++], + email: info[i++], + isMobile: info[i++] === 'Y' ? true : false, + deptName: info[i++], + order: info[i++], + isActive: info[i++] === 'Y' ? true : false, + roleCd: info[i++] as RoleCode, + employeeNum: info[i++], + madn: info[i++], + hardSadn: info[i++], + fmcSadn: info[i++], + callMode: info[i++], + nameEn: info[i++], + nameCn: info[i++], + gradeEn: info[i++], + gradeCn: info[i++], + deptNameEn: info[i++], + deptNameCn: info[i++], + deptSeq: info[i++], + isPrivacyAgree: info[i++] === 'Y' ? true : false, + isValidLogin: info[i++] === 'Y' ? true : false, + employeeType: info[i++] as EmployeeType + }; + } + return { + divCd: message.bodyList[0], + userInfo + } as DataUserResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/dept-user.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/dept-user.ts index af5e2ad5..bfa43384 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/models/dept-user.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/dept-user.ts @@ -9,16 +9,10 @@ import { BodyStringDivider, ProtocolStream } from '@ucap-webmessenger/protocol'; -import { - DeviceType, - FileTransferPermissions, - OrganizationChartPermissions, - DefaultScreen, - VideoConferenceType -} from '@ucap-webmessenger/core'; -import { DeptType, DeptSearchType } from '../types/dept.type'; import { EmployeeType } from '@ucap-webmessenger/protocol-room'; import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; +import { DeptSearchType } from '../types/dept-search.type'; +import { CallMode } from '@ucap-webmessenger/core'; export interface DeptUserRequest extends ProtocolRequest { // DivCD(s) @@ -79,7 +73,7 @@ export interface UserInfoSS { // FMC_SADN fmcSadn: string; // CALL_MODE - callMode: string; + callMode: CallMode; // 사용자명(영어) nameEn: string; // 사용자명(중국어) @@ -150,7 +144,7 @@ export const decodeDeptUserData: ProtocolDecoder = ( const info = userInfo.split(BodyStringDivider); let i = 0; userInfos.push({ - seq: info[i], + seq: Number(info[i]), name: info[i++], profileImageFile: info[i++], grade: info[i++], @@ -168,7 +162,7 @@ export const decodeDeptUserData: ProtocolDecoder = ( madn: info[i++], hardSadn: info[i++], fmcSadn: info[i++], - callMode: info[i++], + callMode: info[i++] as CallMode, nameEn: info[i++], nameCn: info[i++], gradeEn: info[i++], diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/dept.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/dept.ts index 1e5b56ac..faa0bbfc 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/models/dept.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/dept.ts @@ -69,14 +69,14 @@ export const decodeDeptData: ProtocolDecoder = ( const info = deptInfo.split(BodyStringDivider); let i = 0; departmentInfos.push({ - seq: info[i], + seq: Number(info[i]), name: info[i++], companyCode: info[i++], type: info[i++] as DeptType, - rootSeq: info[i++], - parentSeq: info[i++], + rootSeq: Number(info[i++]), + parentSeq: Number(info[i++]), order: info[i++], - depth: info[i++], + depth: Number(info[i++]), isActive: info[i++] === 'Y' ? true : false, nameEn: info[i++], nameCn: info[i++] diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/user-dn.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-dn.ts new file mode 100644 index 00000000..0ba021a5 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-dn.ts @@ -0,0 +1,179 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { EmployeeType } from '@ucap-webmessenger/protocol-room'; +import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; +import { UserDnSearchType } from '../types/user-dn-search.type'; + +export interface UserDnRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 기관코드(s) + companyCode: string; + // 부서SEQ(n) + seq?: number; + // 검색string(s) + search?: string; + // 검색구분(s) + searchType: UserDnSearchType; + // 요청리스트(n) 사용안하면 0 최대 200 + pageListCount?: number; + // 요청페이지(n) 사용안하면 0 처음은 1 + pageCurrent?: number; + // 발신자회사코드(s) + senderCompanyCode: string; + // 발신자임직원유형(s) + senderEmployeeType: EmployeeType; +} + +export interface UserInfoDN { + // 사용자SEQ + seq: number; + // 사용자명 + name: string; + // 사진파일 + profileImageFile: string; + // 직급 + grade: string; + // 업무소개 + intro: string; + // 기관코드 + companyCode: string; + // 핸드폰번호 + hpNumber: string; + // 내선번호 + lineNumber: string; + // 이메일 + email: string; + // 모바일YN + isMobile: boolean; + // 조회순서 + order: string; + // ActiveYN + isActive: boolean; + // 역할코드 + roleCd: RoleCode; + // 사번 + employeeNum: string; + // 부서명 + deptName: string; + // MADN + madn: string; + // HARDPHONE_SADN + hardSadn: string; + // FMC_SADN + fmcSadn: string; + // 사용자명(영어) + nameEn: string; + // 사용자명(중국어) + nameCn: string; + // 직급(영어) + gradeEn: string; + // 직급(중국어) + gradeCn: string; + // 부서명(영어) + deptNameEn: string; + // 부서명(중국어) + deptNameCn: string; +} +export interface UserDnData extends ProtocolStream { + // DivCD(s) + divCd: string; + // {부서정보-S}... + userDnInfos: UserInfoDN[]; +} +export interface UserDnResponse extends ProtocolResponse { + // DivCD(s) + divCd: string; + // 전체갯수(n) + pageTotalCount: number; + // 요청리스트(n) + pageListCount?: number; + // 페이지(n) + pageCurrent?: number; +} + +export const encodeUserDn: ProtocolEncoder = ( + req: UserDnRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.divCd }, + { type: PacketBodyValue.String, value: req.companyCode }, + { type: PacketBodyValue.Integer, value: req.seq || 0 }, + { type: PacketBodyValue.String, value: req.search || '' }, + { type: PacketBodyValue.String, value: req.searchType }, + { + type: PacketBodyValue.Integer, + value: req.pageListCount || 0 + }, + { type: PacketBodyValue.Integer, value: req.pageCurrent || 0 }, + { type: PacketBodyValue.String, value: req.senderCompanyCode }, + { + type: PacketBodyValue.String, + value: req.senderEmployeeType + } + ); + + return bodyList; +}; + +export const decodeUserDnData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userDnInfos: UserInfoDN[] = []; + message.bodyList.slice(1).forEach(userDnInfo => { + const info = userDnInfo.split(BodyStringDivider); + let i = 0; + userDnInfos.push({ + seq: Number(info[i]), + name: info[i++], + profileImageFile: info[i++], + grade: info[i++], + intro: info[i++], + companyCode: info[i++], + hpNumber: info[i++], + lineNumber: info[i++], + email: info[i++], + isMobile: info[i++] === 'Y' ? true : false, + order: info[i++], + isActive: info[i++] === 'Y' ? true : false, + roleCd: info[i++] as RoleCode, + employeeNum: info[i++], + deptName: info[i++], + madn: info[i++], + hardSadn: info[i++], + fmcSadn: info[i++], + nameEn: info[i++], + nameCn: info[i++], + gradeEn: info[i++], + gradeCn: info[i++], + deptNameEn: info[i++], + deptNameCn: info[i++] + }); + }); + return { + divCd: message.bodyList[0], + userDnInfos + } as UserDnData; +}; + +export const decodeUserDn: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + pageTotalCount: message.bodyList[1], + pageListCount: message.bodyList[2], + pageCurrent: message.bodyList[3] + } as UserDnResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/user-id.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-id.ts new file mode 100644 index 00000000..5dc94f41 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-id.ts @@ -0,0 +1,83 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { EmployeeType } from '@ucap-webmessenger/protocol-room'; + +export interface UserIdRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 사용자SEQs(s) + loginSeqs: number[]; + // 발신자회사코드(s) + senderCompanyCode: string; + // 발신자임직원유형(s) + senderEmployeeType: EmployeeType; +} +export interface UserSeqInfo { + // 로그인ID + id: string; + // 사용자SEQ + seq: number; + // 모바일YN + isMobile: boolean; + // 회사코드 + companyCode: string; +} +export interface UserIdData extends ProtocolStream { + // DivCD(s) + divCd: string; + // {SEQ정보}1... + userSeqInfos: UserSeqInfo[]; +} +export interface UserIdResponse extends ProtocolResponse { + // DivCD(s) + divCd: string; +} + +export const encodeUserId: ProtocolEncoder = ( + req: UserIdRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.divCd }, + { type: PacketBodyValue.Integer, value: req.loginSeqs.join(',') }, + { type: PacketBodyValue.String, value: req.senderCompanyCode }, + { type: PacketBodyValue.String, value: req.senderEmployeeType } + ); + + return bodyList; +}; + +export const decodeUserIdData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userSeqInfos: UserSeqInfo[] = []; + message.bodyList.slice(1).forEach(userInfo => { + const info = userInfo.split(BodyStringDivider); + userSeqInfos.push({ + id: info[0], + seq: Number(info[1]), + isMobile: info[2] === 'Y' ? true : false, + companyCode: info[3] + }); + }); + return { + divCd: message.bodyList[0], + userSeqInfos + } as UserIdData; +}; + +export const decodeUserId: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { divCd: message.bodyList[0] } as UserIdResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/models/user-seq.ts b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-seq.ts new file mode 100644 index 00000000..0f416fd4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/models/user-seq.ts @@ -0,0 +1,218 @@ +import { + ProtocolRequest, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { EmployeeType } from '@ucap-webmessenger/protocol-room'; +import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; +import { UserInfoSS } from './dept-user'; + +export interface UserSeqRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 로그인IDs(s) + loginIds: string[]; + // 기관코드(s) + companyCode: string; + // 상세정보여부(s) + isDetail: boolean; + // 발신자회사코드(s) + senderCompanyCode: string; + // 발신자임직원유형(s) + senderEmployeeType: EmployeeType; +} +export interface UserInfoF { + // 사용자SEQ + seq: number; + // 사용자명 + name: string; + // 사진파일 + profileImageFile: string; + // 직급 + grade: string; + // 업무소개 + intro: string; + // 기관코드 + companyCode: string; + // 핸드폰번호 + hpNumber: string; + // 내선번호 + lineNumber: string; + // 이메일 + email: string; + // 모바일YN + isMobile: boolean; + // 부서명 + deptName: string; + // 즐.찾 여부 + isFavorit: boolean; + // 친구여부 + isBuddy: boolean; + // ActiveYN + isActive: boolean; + // 역할코드 + roleCd: RoleCode; + // 사번 + employeeNum: string; + // MADN + madn: string; + // HARDPHONE_SADN + hardSadn: string; + // FMC_SADN + fmcSadn: string; + // 사용자명(영어) + nameEn: string; + // 사용자명(중국어) + nameCn: string; + // 직급(영어) + gradeEn: string; + // 직급(중국어) + gradeCn: string; + // 부서명(영어) + deptNameEn: string; + // 부서명(중국어) + deptNameCn: string; + // 이용약관동의여부YN + isPrivacyAgree: boolean; + // 유효접속여부YN + isValidLogin: boolean; + // 임직원유형(s) + employeeType: EmployeeType; + // 별명 + nickName: string; +} +export interface UserSeqData extends ProtocolStream { + // DivCD(s) + divCd: string; + // {사용자정보-F}... + userInfos: UserInfoF[]; +} +export interface UserSeqData2 extends ProtocolStream { + // DivCD(s) + divCd: string; + // {사용자정보-SS}... + userInfos: UserInfoSS[]; +} + +export const encodeUserSeq: ProtocolEncoder = ( + req: UserSeqRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.divCd }, + { type: PacketBodyValue.String, value: req.loginIds.join(',') }, + { type: PacketBodyValue.String, value: req.companyCode }, + { type: PacketBodyValue.String, value: req.isDetail ? 'Y' : 'N' }, + { type: PacketBodyValue.String, value: req.senderCompanyCode }, + { type: PacketBodyValue.String, value: req.senderEmployeeType } + ); + + return bodyList; +}; + +export const decodeUserSeqData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userInfos: UserInfoF[] = []; + message.bodyList.slice(1).forEach(userInfo => { + const info = userInfo.split(BodyStringDivider); + let i = 0; + userInfos.push({ + seq: Number(info[i]), + name: info[i++], + profileImageFile: info[i++], + grade: info[i++], + intro: info[i++], + companyCode: info[i++], + hpNumber: info[i++], + lineNumber: info[i++], + email: info[i++], + isMobile: info[i++] === 'Y' ? true : false, + deptName: info[i++], + isFavorit: info[i++] === 'Y' ? true : false, + isBuddy: info[i++] === 'Y' ? true : false, + isActive: info[i++] === 'Y' ? true : false, + roleCd: info[i++] as RoleCode, + employeeNum: info[i++], + madn: info[i++], + hardSadn: info[i++], + fmcSadn: info[i++], + nameEn: info[i++], + nameCn: info[i++], + gradeEn: info[i++], + gradeCn: info[i++], + deptNameEn: info[i++], + deptNameCn: info[i++], + isPrivacyAgree: info[i++] === 'Y' ? true : false, + isValidLogin: info[i++] === 'Y' ? true : false, + employeeType: info[i++] as EmployeeType, + nickName: info[i++] + } as UserInfoF); + }); + return { + divCd: message.bodyList[0], + userInfos + } as UserSeqData; +}; + +export const decodeUserSeqData2: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userInfos: UserInfoSS[] = []; + message.bodyList.slice(1).forEach(userInfo => { + const info = userInfo.split(BodyStringDivider); + let i = 0; + userInfos.push({ + seq: Number(info[i]), + name: info[i++], + profileImageFile: info[i++], + grade: info[i++], + intro: info[i++], + companyCode: info[i++], + hpNumber: info[i++], + lineNumber: info[i++], + email: info[i++], + isMobile: info[i++] === 'Y' ? true : false, + deptName: info[i++], + order: info[i++], + isActive: info[i++] === 'Y' ? true : false, + roleCd: info[i++] as RoleCode, + employeeNum: info[i++], + madn: info[i++], + hardSadn: info[i++], + fmcSadn: info[i++], + callMode: info[i++], + nameEn: info[i++], + nameCn: info[i++], + gradeEn: info[i++], + gradeCn: info[i++], + deptNameEn: info[i++], + deptNameCn: info[i++], + deptSeq: info[i++], + isPrivacyAgree: info[i++] === 'Y' ? true : false, + isValidLogin: info[i++] === 'Y' ? true : false, + employeeType: info[i++] as EmployeeType + }); + }); + return { + divCd: message.bodyList[0], + userInfos + } as UserSeqData2; +}; + +// export const decodeDeptUser: ProtocolDecoder = ( +// message: ProtocolMessage +// ) => { +// return { +// divCd: message.bodyList[0], +// pageTotalCount: message.bodyList[1], +// pageListCount: message.bodyList[2], +// pageCurrent: message.bodyList[3] +// } as DeptUserResponse; +// }; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts b/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts index e79ac75f..26abcd33 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/services/query-protocol.service.ts @@ -16,7 +16,22 @@ import { SSVC_TYPE_QUERY_DEPT_DATA, SSVC_TYPE_QUERY_DEPT_USER_RES, SSVC_TYPE_QUERY_DEPT_USER_DATA, - SSVC_TYPE_QUERY_DEPT_USER_REQ + SSVC_TYPE_QUERY_DEPT_USER_REQ, + SSVC_TYPE_QUERY_USER_SEQ_REQ, + SSVC_TYPE_QUERY_USER_SEQ_RES, + SSVC_TYPE_QUERY_USER_SEQ_DATA, + SSVC_TYPE_QUERY_USER_SEQ_DATA2, + SSVC_TYPE_QUERY_USER_ID_REQ, + SSVC_TYPE_QUERY_USER_ID_RES, + SSVC_TYPE_QUERY_USER_ID_DATA, + SSVC_TYPE_QUERY_USER_BY_DN_REQ, + SSVC_TYPE_QUERY_USER_BY_DN_RES, + SSVC_TYPE_QUERY_USER_BY_DN_DATA, + SSVC_TYPE_QUERY_DATA_USER_REQ, + SSVC_TYPE_QUERY_EXT_DATA_USER_REQ, + SSVC_TYPE_QUERY_DEPT_USER2_REQ, + SSVC_TYPE_QUERY_DEPT_USER2_DATA, + SSVC_TYPE_QUERY_DEPT_USER2_RES } from '../types/service'; import { DeptRequest, @@ -34,6 +49,42 @@ import { DeptUserData, DeptUserResponse } from '../models/dept-user'; +import { + UserSeqData, + UserSeqData2, + encodeUserSeq, + decodeUserSeqData, + decodeUserSeqData2, + UserSeqRequest +} from '../models/user-seq'; +import { + UserIdRequest, + UserIdResponse, + UserIdData, + encodeUserId, + decodeUserId, + decodeUserIdData +} from '../models/user-id'; +import { + UserDnRequest, + UserDnResponse, + UserDnData, + encodeUserDn, + decodeUserDnData, + decodeUserDn +} from '../models/user-dn'; +import { + DataUserRequest, + DataUserResponse, + encodeDataUser, + decodeDataUser +} from '../models/data-user'; +import { + DataUserExtRequest, + DataUserExtResponse, + encodeDataUserExt, + decodeDataUserExt +} from '../models/data-user-ext'; @Injectable({ providedIn: 'root' @@ -93,4 +144,140 @@ export class QueryProtocolService { }) ); } + public deptUser2( + req: DeptUserRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_DEPT_USER2_REQ, + ...encodeDeptUser(req) + ) + .pipe( + takeWhile( + res => SSVC_TYPE_QUERY_DEPT_USER2_RES !== res.subServiceType, + true + ), + map(res => { + if (SSVC_TYPE_QUERY_DEPT_USER2_DATA === res.subServiceType) { + return { + ...decodeDeptUserData(res), + Type: SSVC_TYPE_QUERY_DEPT_USER2_DATA + }; + } + + return { + ...decodeDeptUser(res), + Type: SSVC_TYPE_QUERY_DEPT_USER2_RES + }; + }) + ); + } + + public userSeq(req: UserSeqRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_USER_SEQ_REQ, + ...encodeUserSeq(req) + ) + .pipe( + takeWhile( + res => SSVC_TYPE_QUERY_USER_SEQ_RES !== res.subServiceType, + true + ), + map(res => { + if (SSVC_TYPE_QUERY_USER_SEQ_DATA === res.subServiceType) { + return { + ...decodeUserSeqData(res), + Type: SSVC_TYPE_QUERY_USER_SEQ_DATA + }; + } else if (SSVC_TYPE_QUERY_USER_SEQ_DATA2 === res.subServiceType) { + return { + ...decodeUserSeqData2(res), + Type: SSVC_TYPE_QUERY_USER_SEQ_DATA2 + }; + } + }) + ); + } + public userId(req: UserIdRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_USER_ID_REQ, + ...encodeUserId(req) + ) + .pipe( + takeWhile( + res => SSVC_TYPE_QUERY_USER_ID_RES !== res.subServiceType, + true + ), + map(res => { + if (SSVC_TYPE_QUERY_USER_ID_DATA === res.subServiceType) { + return { + ...decodeUserIdData(res), + Type: SSVC_TYPE_QUERY_USER_SEQ_DATA + }; + } + + return { + ...decodeUserId(res), + Type: SSVC_TYPE_QUERY_USER_ID_RES + }; + }) + ); + } + public userDn(req: UserDnRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_USER_BY_DN_REQ, + ...encodeUserDn(req) + ) + .pipe( + takeWhile( + res => SSVC_TYPE_QUERY_USER_BY_DN_RES !== res.subServiceType, + true + ), + map(res => { + if (SSVC_TYPE_QUERY_USER_BY_DN_DATA === res.subServiceType) { + return { + ...decodeUserDnData(res), + Type: SSVC_TYPE_QUERY_USER_BY_DN_DATA + }; + } + + return { + ...decodeUserDn(res), + Type: SSVC_TYPE_QUERY_USER_BY_DN_RES + }; + }) + ); + } + + public dataUser(req: DataUserRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_DATA_USER_REQ, + ...encodeDataUser(req) + ) + .pipe( + take(1), + map(res => decodeDataUser(res)) + ); + } + public dataUserExt(req: DataUserExtRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_QUERY_DATA, + SSVC_TYPE_QUERY_EXT_DATA_USER_REQ, + ...encodeDataUserExt(req) + ) + .pipe( + take(1), + map(res => decodeDataUserExt(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/types/dept-search.type.ts b/projects/ucap-webmessenger-protocol-query/src/lib/types/dept-search.type.ts new file mode 100644 index 00000000..5934d474 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/types/dept-search.type.ts @@ -0,0 +1,10 @@ +export enum DeptSearchType { + // A: 부서, 인원 + All = 'A', + // U: 인원 + User = 'U', + // D: 부서 + Department = 'D', + // M: 다중부서 cf) 여러 부서(하위전체)를 쿼리할 때 1, 2, 3, 4..이렇게 부서SEQ들을, 로 연결해서 보냄 (검색string 필드를 사용함) + MultiDepartment = 'M' +} diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/types/dept.type.ts b/projects/ucap-webmessenger-protocol-query/src/lib/types/dept.type.ts index 2783f927..18c4a5e7 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/types/dept.type.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/types/dept.type.ts @@ -6,14 +6,3 @@ export enum DeptType { // T: 부서 Team = 'T' } - -export enum DeptSearchType { - // A: 부서, 인원 - All = 'A', - // U: 인원 - User = 'U', - // D: 부서 - Department = 'D', - // M: 다중부서 cf) 여러 부서(하위전체)를 쿼리할 때 1, 2, 3, 4..이렇게 부서SEQ들을, 로 연결해서 보냄 (검색string 필드를 사용함) - MultiDepartment = 'M' -} diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-query/src/lib/types/service.ts index efc92581..1cb064a2 100644 --- a/projects/ucap-webmessenger-protocol-query/src/lib/types/service.ts +++ b/projects/ucap-webmessenger-protocol-query/src/lib/types/service.ts @@ -8,8 +8,11 @@ export const SSVC_TYPE_QUERY_DEPT_REQ = 11; // 부서 정보 쿼리 요청 export const SSVC_TYPE_QUERY_DEPT_DATA = 12; // export const SSVC_TYPE_QUERY_DEPT_RES = 13; // export const SSVC_TYPE_QUERY_DEPT_USER_REQ = 14; // 사용자 검색 쿼리 요청 -export const SSVC_TYPE_QUERY_DEPT_USER_DATA = 15; // -export const SSVC_TYPE_QUERY_DEPT_USER_RES = 16; // +export const SSVC_TYPE_QUERY_DEPT_USER_DATA = 15; +export const SSVC_TYPE_QUERY_DEPT_USER_RES = 16; +export const SSVC_TYPE_QUERY_DEPT_USER2_REQ = 54; // 사용자 검색 쿼리 요청2 (부서 LIKE 검색) +export const SSVC_TYPE_QUERY_DEPT_USER2_DATA = 55; +export const SSVC_TYPE_QUERY_DEPT_USER2_RES = 56; export const SSVC_TYPE_QUERY_TEAM_CONTACT_USER_REQ = 17; // 공용 주소록 검색 쿼리 요청 export const SSVC_TYPE_QUERY_TEAM_CONTACT_USER_DATA = 18; // export const SSVC_TYPE_QUERY_TEAM_CONTACT_USER_RES = 19; // @@ -25,10 +28,10 @@ export const SSVC_TYPE_QUERY_USER_BY_DN_DATA = 32; // export const SSVC_TYPE_QUERY_USER_BY_DN_RES = 33; // 사용자 정보 검색 응답(DN으로) export const SSVC_TYPE_QUERY_MY_GROUP_REQ = 41; // 정렬된 그룹 SEQs 정보 요청 export const SSVC_TYPE_QUERY_MY_GROUP_RES = 42; // 정렬된 그룹 SEQs 정보 응답 -export const SSVC_TYPE_QUERY_CONFIRM_USER_REQ = 51; // 사용자 확인 요청 -export const SSVC_TYPE_QUERY_CONFIRM_USER_RES = 52; // 사용자 확인 응답 +export const SSVC_TYPE_QUERY_MY_GROUP_REQ2 = 43; // 정렬된 그룹 SEQs 정보 요청 +export const SSVC_TYPE_QUERY_MY_GROUP_RES2 = 44; // 정렬된 그룹 SEQs 정보 응답 export const SSVC_TYPE_QUERY_AUTH_REQ = 91; // 사용자 권한 정보 요청 export const SSVC_TYPE_QUERY_AUTH_RES = 92; // 사용자 권한 정보 응답 -export const SSVC_TYPE_QUERY_CONTACT_VCARD_REQ = 101; // 명함주소록(거래처) 검색 요청 -export const SSVC_TYPE_QUERY_CONTACT_VCARD_DATA = 102; // 명함주소록(거래처) 데이터 -export const SSVC_TYPE_QUERY_CONTACT_VCARD_RES = 103; // 명함주소록(거래처) 검색 요청 응답 +export const SSVC_TYPE_QUERY_VALID_USER_REQ = 93; +export const SSVC_TYPE_QUERY_VALID_USER_DATA = 94; +export const SSVC_TYPE_QUERY_VALID_USER_RES = 95; diff --git a/projects/ucap-webmessenger-protocol-query/src/lib/types/user-dn-search.type.ts b/projects/ucap-webmessenger-protocol-query/src/lib/types/user-dn-search.type.ts new file mode 100644 index 00000000..c1b99fa4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-query/src/lib/types/user-dn-search.type.ts @@ -0,0 +1,6 @@ +export enum UserDnSearchType { + // D: 전화번호검색(HP_NUMBER, HARDPHONE_SADN, FMC_SADN) + Number = 'D', + // C: 이름검색(사용자명, 부서명) + Character = 'C' +} diff --git a/projects/ucap-webmessenger-protocol-query/src/public-api.ts b/projects/ucap-webmessenger-protocol-query/src/public-api.ts index 8e28590a..0b072b39 100644 --- a/projects/ucap-webmessenger-protocol-query/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-query/src/public-api.ts @@ -3,12 +3,19 @@ */ export * from './lib/models/auth'; -export * from './lib/models/dept'; +export * from './lib/models/data-user-ext'; +export * from './lib/models/data-user'; export * from './lib/models/dept-user'; +export * from './lib/models/dept'; +export * from './lib/models/user-dn'; +export * from './lib/models/user-id'; +export * from './lib/models/user-seq'; export * from './lib/services/query-protocol.service'; +export * from './lib/types/dept-search.type'; export * from './lib/types/dept.type'; export * from './lib/types/service'; +export * from './lib/types/user-dn-search.type'; export * from './lib/ucap-query-protocol.module'; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts index 87fbab49..53b9b9c4 100644 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts @@ -207,13 +207,13 @@ export const decodeInfoData: ProtocolDecoder = ( finalEventType: info[3] as EventType, finalEventMessage: info[4], finalEventDate: info[5], - joinUserCount: info[6], - noReadCnt: info[7], + joinUserCount: Number(info[6]), + noReadCnt: Number(info[7]), isAlarm: info[8] !== 'N' ? true : false, isJoinRoom: info[9] === 'Y' ? true : false, - expiredFileStdSeq: info[10], + expiredFileStdSeq: Number(info[10]), isTimeRoom: info[11] === 'Y' ? true : false, - timeRoomInterval: info[11] !== 'Y' ? 0 : info[12] || 0 + timeRoomInterval: info[11] !== 'Y' ? 0 : Number(info[12]) || 0 }; } } @@ -231,11 +231,11 @@ export const decodeUserShortData: ProtocolDecoder = ( message.bodyList.slice(1).forEach(userInfo => { const info = userInfo.split(BodyStringDivider); userInfos.push({ - seq: info[0], + seq: Number(info[0]), name: info[1], profileImageFile: info[2], isJoinRoom: info[3], - lastReadEventSeq: info[4], + lastReadEventSeq: Number(info[4]), madn: info[5], hardSadn: info[6], fmcSadn: info[7], @@ -261,7 +261,7 @@ export const decodeUserData: ProtocolDecoder = ( message.bodyList.slice(1).forEach(userInfo => { const info = userInfo.split(BodyStringDivider); userInfos.push({ - seq: info[0], + seq: Number(info[0]), name: info[1], profileImageFile: info[2], grade: info[3], diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/buddy.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/buddy.ts new file mode 100644 index 00000000..1a6bb3eb --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/buddy.ts @@ -0,0 +1,36 @@ +import { + ProtocolResponse, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; +import { StatusCode } from '@ucap-webmessenger/core'; +import { StatusInfo } from './status'; + +export interface BuddyResponse extends ProtocolResponse { + // {상태정보}... + statusInfos: StatusInfo[]; +} + +export const decodeBuddy: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const statusInfos: StatusInfo[] = []; + message.bodyList.forEach(statusInfo => { + const info = statusInfo.split(BodyStringDivider); + let idx = 0; + statusInfos.push({ + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode + }); + }); + return { + statusInfos + } as BuddyResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/bulk.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/bulk.ts new file mode 100644 index 00000000..4166e4dd --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/bulk.ts @@ -0,0 +1,95 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { StatusType, StatusCode } from '@ucap-webmessenger/core'; +import { StatusInfo } from './status'; +import { + TerminalStatusInfo, + TerminalStatusNumber +} from '../types/terminal-status.type'; + +export interface BulkInfoRequest extends ProtocolRequest { + // DivCD(s) + divCd: string; + // 사용자SEQ(n)... + userSeqs: number[]; +} +export interface StatusBulkInfo extends StatusInfo { + // 사용자SEQ + // 상태코드(PC) + // 상태코드(통화) + // 상태코드(모바일) + // 상태코드(PC화상) + // 상태메시지 + // 상태코드(Mobile화상) + // 상태코드(iMessenger) + + // 단말상태정보(s) + terminalStatus: TerminalStatusInfo; + // 단말상태번호(n) + terminalStatusNumber: TerminalStatusNumber; +} +export interface BulkInfoData extends ProtocolStream { + // DivCD(s) + divCd: string; + // {상태정보Bulk}... + statusBulkInfos: StatusBulkInfo[]; +} +export interface BulkInfoResponse extends ProtocolResponse { + // DivCD(s) + divCd: string; +} + +export const encodeBulkInfo: ProtocolEncoder = ( + req: BulkInfoRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + return bodyList; +}; + +export const decodeBulkInfo: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0] + } as BulkInfoResponse; +}; + +export const decodeBulkInfoData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const statusBulkInfos: StatusBulkInfo[] = []; + message.bodyList.slice(1).forEach(statusBulkInfo => { + const info = statusBulkInfo.split(BodyStringDivider); + let idx = 0; + statusBulkInfos.push({ + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode, + terminalStatus: info[idx++] as TerminalStatusInfo, + terminalStatusNumber: Number(info[idx++]) as TerminalStatusNumber + }); + }); + return { + divCd: message.bodyList[0], + statusBulkInfos + } as BulkInfoData; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/message-update.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/message-update.ts new file mode 100644 index 00000000..93f40567 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/message-update.ts @@ -0,0 +1,45 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; +import { MessageIndexType } from '../types/message-index.type'; + +export interface MessageUpdateRequest extends ProtocolRequest { + // 상태타입(s) + index: MessageIndexType; + // 상태메시지(s) + statusMessage: string; +} + +export interface MessageUpdateResponse extends ProtocolResponse { + // 상태타입(s) + index: MessageIndexType; + // 상태메시지(s) + statusMessage: string; +} + +export const encodeMessageUpdate: ProtocolEncoder = ( + req: MessageUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.Integer, value: req.index }, + { type: PacketBodyValue.String, value: req.statusMessage } + ); + return bodyList; +}; + +export const decodeMessageUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + index: message.bodyList[0] as MessageIndexType, + statusMessage: message.bodyList[1] + } as MessageUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/status.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/status.ts new file mode 100644 index 00000000..675aa20e --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/status.ts @@ -0,0 +1,96 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; +import { StatusType, StatusCode } from '@ucap-webmessenger/core'; + +export interface StatusRequest extends ProtocolRequest { + // 상태타입(s) + statusDivisionType: StatusType; + // 상태코드(s) + statusType: StatusCode; + // 상태메시지(s) (상태타입 : M, 상태코드: B 일때, 사용함) + statusMessage?: string; +} + +export interface StatusResponse extends ProtocolResponse { + // 상태타입(s) + statusDivisionType: StatusType; + // 상태코드(s) + statusType: StatusCode; + // 상태메시지(s) (상태타입 : M, 상태코드: B 일때, 사용함) + statusMessage: string; +} + +export interface StatusInfo { + // 사용자SEQ + userSeq: number; + // 상태코드(PC) + pcStatus: StatusCode; + // 상태코드(통화) + phoneStatus: StatusCode; + // 상태코드(모바일) + mobileStatus: StatusCode; + // 상태코드(PC화상) + conferenceStatus: StatusCode; + // 상태메시지 + statusMessage: string; + // 상태코드(Mobile화상) + mobileConferenceStatus: StatusCode; + // 상태코드(iMessenger) + imessengerStatus: StatusCode; +} +export interface StatusNotification extends StatusInfo, ProtocolNotification {} + +export const encodeStatus: ProtocolEncoder = ( + req: StatusRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { + type: PacketBodyValue.String, + value: req.statusDivisionType + }, + { type: PacketBodyValue.String, value: req.statusType }, + { + type: PacketBodyValue.String, + value: req.statusMessage || '' + } + ); + return bodyList; +}; + +export const decodeStatus: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + statusDivisionType: message.bodyList[0] as StatusType, + statusType: message.bodyList[1] as StatusCode, + statusMessage: message.bodyList[2] + } as StatusResponse; +}; + +export const decodeStatusNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const info = message.bodyList[0].split(BodyStringDivider); + let idx = 0; + return { + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode + } as StatusNotification; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/subscribe.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/subscribe.ts new file mode 100644 index 00000000..f96a47ff --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/subscribe.ts @@ -0,0 +1,93 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider, + ProtocolStream +} from '@ucap-webmessenger/protocol'; +import { StatusCode } from '@ucap-webmessenger/core'; +import { StatusInfo } from './status'; + +export interface SubscribeRequest extends ProtocolRequest { + // 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface SubscribeResponse extends ProtocolResponse { + // {상태정보}... + statusInfos: StatusInfo[]; +} + +/** + * @deprecated not support server + */ +export interface SubscribeData extends ProtocolStream { + // {상태정보}... + statusInfos: StatusInfo[]; +} + +export const encodeSubscribe: ProtocolEncoder = ( + req: SubscribeRequest +) => { + const bodyList: PacketBody[] = []; + + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + return bodyList; +}; + +export const decodeSubscribe: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const statusInfos: StatusInfo[] = []; + message.bodyList.forEach(statusInfo => { + const info = statusInfo.split(BodyStringDivider); + let idx = 0; + statusInfos.push({ + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode + }); + }); + return { + statusInfos + } as SubscribeResponse; +}; + +/** + * @deprecated not support server + */ +// tslint:disable-next-line: deprecation +export const decodeSubscribeData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const statusInfos: StatusInfo[] = []; + message.bodyList.forEach(statusInfo => { + const info = statusInfo.split(BodyStringDivider); + let idx = 0; + statusInfos.push({ + userSeq: Number(info[idx]), + pcStatus: info[idx++] as StatusCode, + phoneStatus: info[idx++] as StatusCode, + mobileStatus: info[idx++] as StatusCode, + conferenceStatus: info[idx++] as StatusCode, + statusMessage: info[idx++], + mobileConferenceStatus: info[idx++] as StatusCode, + imessengerStatus: info[idx++] as StatusCode + }); + }); + return { + statusInfos + // tslint:disable-next-line: deprecation + } as SubscribeData; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/models/unsubscribe.ts b/projects/ucap-webmessenger-protocol-status/src/lib/models/unsubscribe.ts new file mode 100644 index 00000000..d4bc92cb --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/models/unsubscribe.ts @@ -0,0 +1,29 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; +import { StatusInfo } from './status'; + +export interface UnSubscribeRequest extends ProtocolRequest { + // 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface UnSubscribeResponse extends ProtocolResponse { + // {상태정보}... + statusInfos: StatusInfo[]; +} + +export const encodeUnSubscribe: ProtocolEncoder = ( + req: UnSubscribeRequest +) => { + const bodyList: PacketBody[] = []; + + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + return bodyList; +}; diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/services/status-protocol.service.ts b/projects/ucap-webmessenger-protocol-status/src/lib/services/status-protocol.service.ts index d6ee341a..04c41a72 100644 --- a/projects/ucap-webmessenger-protocol-status/src/lib/services/status-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-status/src/lib/services/status-protocol.service.ts @@ -1,8 +1,151 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take, takeWhile } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + StatusRequest, + encodeStatus, + decodeStatus, + StatusResponse +} from '../models/status'; +import { + SVC_TYPE_STATUS, + SSVC_TYPE_STATUS_REQ, + SSVC_TYPE_STATUS_BULK_INFO_REQ, + SSVC_TYPE_STATUS_BULK_INFO_RES, + SSVC_TYPE_STATUS_BULK_INFO_DATA, + SSVC_TYPE_STATUS_BUDDY_REQ, + SSVC_TYPE_STATUS_MSG_UPD_REQ, + SSVC_TYPE_STATUS_SUBSCRIPT_REQ, + SSVC_TYPE_STATUS_UNSUBSCRIPT_REQ +} from '../types/service'; +import { + BulkInfoRequest, + BulkInfoResponse, + BulkInfoData, + encodeBulkInfo, + decodeBulkInfo, + decodeBulkInfoData +} from '../models/bulk'; +import { BuddyResponse, decodeBuddy } from '../models/buddy'; +import { + MessageUpdateRequest, + MessageUpdateResponse, + encodeMessageUpdate, + decodeMessageUpdate +} from '../models/message-update'; +import { + SubscribeRequest, + SubscribeResponse, + decodeSubscribe, + encodeSubscribe +} from '../models/subscribe'; +import { UnSubscribeRequest, encodeUnSubscribe } from '../models/unsubscribe'; + @Injectable({ providedIn: 'root' }) export class StatusProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public status(req: StatusRequest): Observable { + return this.protocolService + .call(SVC_TYPE_STATUS, SSVC_TYPE_STATUS_REQ, ...encodeStatus(req)) + .pipe( + take(1), + map(res => { + return decodeStatus(res); + }) + ); + } + + public buddy(): Observable { + return this.protocolService + .call(SVC_TYPE_STATUS, SSVC_TYPE_STATUS_BUDDY_REQ) + .pipe( + take(1), + map(res => { + return decodeBuddy(res); + }) + ); + } + + public bulkInfo( + req: BulkInfoRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_STATUS, + SSVC_TYPE_STATUS_BULK_INFO_REQ, + ...encodeBulkInfo(req) + ) + .pipe( + takeWhile( + res => SSVC_TYPE_STATUS_BULK_INFO_RES !== res.subServiceType, + true + ), + map(res => { + if (SSVC_TYPE_STATUS_BULK_INFO_DATA === res.subServiceType) { + return { + ...decodeBulkInfoData(res), + Type: SSVC_TYPE_STATUS_BULK_INFO_DATA + }; + } + return { + ...decodeBulkInfo(res), + Type: SSVC_TYPE_STATUS_BULK_INFO_RES + }; + }) + ); + } + + public messageUpdate( + req: MessageUpdateRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_STATUS, + SSVC_TYPE_STATUS_MSG_UPD_REQ, + ...encodeMessageUpdate(req) + ) + .pipe( + take(1), + map(res => { + return decodeMessageUpdate(res); + }) + ); + } + + /** + * Only Use 1:1 Chat Room and must be using unsubscribe method. + * @param req SubscribeRequest + */ + public subscribe(req: SubscribeRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_STATUS, + SSVC_TYPE_STATUS_SUBSCRIPT_REQ, + ...encodeSubscribe(req) + ) + .pipe( + take(1), + map(res => { + return decodeSubscribe(res); + }) + ); + } + + /** + * Only Use 1:1 Chat Room and must be using subscribe method. + * @param req UnSubscribeRequest + */ + public unSubscribe(req: UnSubscribeRequest): void { + return this.protocolService.send( + SVC_TYPE_STATUS, + SSVC_TYPE_STATUS_UNSUBSCRIPT_REQ, + ...encodeUnSubscribe(req) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/types/message-index.type.ts b/projects/ucap-webmessenger-protocol-status/src/lib/types/message-index.type.ts new file mode 100644 index 00000000..664a563d --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/types/message-index.type.ts @@ -0,0 +1,5 @@ +export enum MessageIndexType { + First = 1, + Second = 2, + Third = 3 +} diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-status/src/lib/types/service.ts new file mode 100644 index 00000000..f31754a1 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/types/service.ts @@ -0,0 +1,18 @@ +export const SVC_TYPE_STATUS = 3; // 상태 +export const SSVC_TYPE_STATUS_REQ = 1; // 상태변경 요청 +export const SSVC_TYPE_STATUS_RES = 2; // 상태변경 응답 +export const SSVC_TYPE_STATUS_NOTI = 3; // 상태변경 알림 +export const SSVC_TYPE_STATUS_BUDDY_REQ = 11; // 친구상태정보요청 +export const SSVC_TYPE_STATUS_BUDDY_RES = 12; // 친구상태정보응답 +export const SSVC_TYPE_STATUS_SUBSCRIPT_REQ = 31; // 구독 요청 +export const SSVC_TYPE_STATUS_SUBSCRIPT_DATA = 32; // 구독 요청한 사용자상태 +export const SSVC_TYPE_STATUS_SUBSCRIPT_RES = 33; // 구독 응답 +export const SSVC_TYPE_STATUS_UNSUBSCRIPT_REQ = 34; // 구독 해지 요청 +export const SSVC_TYPE_STATUS_UNSUBSCRIPT_RES = 35; // 구독 해지 응답 +export const SSVC_TYPE_STATUS_MSG_UPD_REQ = 41; // 상태 메시지 요청 +export const SSVC_TYPE_STATUS_MSG_UPD_RES = 42; // 상태 메시지 응답 +export const SSVC_TYPE_STATUS_BULK_REQ = 51; // 상태변경 Bulk 요청 +export const SSVC_TYPE_STATUS_BULK_RES = 53; // 상태변경 Bulk 응답 +export const SSVC_TYPE_STATUS_BULK_INFO_REQ = 54; // 상태정보요청 Bulk 요청 +export const SSVC_TYPE_STATUS_BULK_INFO_DATA = 55; // 상태정보요청 Bulk 정보 +export const SSVC_TYPE_STATUS_BULK_INFO_RES = 56; // 상태정보요청 Bulk 응답 diff --git a/projects/ucap-webmessenger-protocol-status/src/lib/types/terminal-status.type.ts b/projects/ucap-webmessenger-protocol-status/src/lib/types/terminal-status.type.ts new file mode 100644 index 00000000..80b92be4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-status/src/lib/types/terminal-status.type.ts @@ -0,0 +1,25 @@ +export enum TerminalStatusInfo { + // TERMINAL_STATE_UNKNOWN 0 + Unknown = 'TERMINAL_STATE_UNKNOWN', + // TERMINAL_STATE_IDLE 1 + Idle = 'TERMINAL_STATE_IDLE', + // TERMINAL_STATE_BUSY 2 + Busy = 'TERMINAL_STATE_BUSY', + // TERMINAL_STATE_HELD 3 + Held = 'TERMINAL_STATE_HELD', + // TERMINAL_STATE_ALERTING 4 + Alerting = 'TERMINAL_STATE_ALERTING' +} + +export enum TerminalStatusNumber { + // TERMINAL_STATE_UNKNOWN 0 + Unknown = 0, + // TERMINAL_STATE_IDLE 1 + Idle = 1, + // TERMINAL_STATE_BUSY 2 + Busy = 2, + // TERMINAL_STATE_HELD 3 + Held = 3, + // TERMINAL_STATE_ALERTING 4 + Alerting = 4 +} diff --git a/projects/ucap-webmessenger-protocol-status/src/public-api.ts b/projects/ucap-webmessenger-protocol-status/src/public-api.ts index 9a2a652f..037c6d9b 100644 --- a/projects/ucap-webmessenger-protocol-status/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-status/src/public-api.ts @@ -2,6 +2,17 @@ * Public API Surface of ucap-webmessenger-protocol-status */ +export * from './lib/models/buddy'; +export * from './lib/models/bulk'; +export * from './lib/models/message-update'; +export * from './lib/models/status'; +export * from './lib/models/subscribe'; +export * from './lib/models/unsubscribe'; + export * from './lib/services/status-protocol.service'; +export * from './lib/types/message-index.type'; +export * from './lib/types/service'; +export * from './lib/types/terminal-status.type'; + export * from './lib/ucap-status-protocol.module'; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts index 62d0dd11..95e9b49f 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts @@ -70,7 +70,7 @@ export const decodeGroupData: ProtocolDecoder = ( message.bodyList.forEach(buddyinfo => { const info = buddyinfo.split(BodyStringDivider); groupInfos.push({ - seq: info[0], + seq: Number(info[0]), name: info[1], isActive: info[2] === 'Y' ? true : false, userSeqStr: info[3] diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts index 612dd4b9..4410721d 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts @@ -80,11 +80,11 @@ export const decodeRoomData: ProtocolDecoder = ( finalEventType: info[3] as EventType, finalEventMessage: info[4], finalEventDate: info[5], - joinUserCount: info[6], - noReadCnt: info[7], + joinUserCount: Number(info[6]), + noReadCnt: Number(info[7]), isAlarm: info[8] !== 'N' ? true : false, isJoinRoom: info[9] === 'Y' ? true : false, - expiredFileStdSeq: info[10], + expiredFileStdSeq: Number(info[10]), isTimeRoom: info[11] === 'Y' ? true : false, timeRoomInterval: info[11] !== 'Y' ? 0 : info[12] || 0 }); @@ -104,11 +104,11 @@ export const decodeRoomUserData: ProtocolDecoder = ( message.bodyList.slice(1).forEach(userInfo => { const info = userInfo.split(BodyStringDivider); userInfos.push({ - seq: info[0], + seq: Number(info[0]), name: info[1], profileImageFile: info[2], isJoinRoom: info[3], - lastReadEventSeq: info[4], + lastReadEventSeq: Number(info[4]), madn: info[5], hardSadn: info[6], fmcSadn: info[7], @@ -134,7 +134,7 @@ export const decodeRoomUserDataDetail: ProtocolDecoder = ( message.bodyList.slice(1).forEach(userInfo => { const info = userInfo.split(BodyStringDivider); userInfos.push({ - seq: info[0], + seq: Number(info[0]), name: info[1], profileImageFile: info[2], grade: info[3],