diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-add.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-add.ts new file mode 100644 index 00000000..64416f74 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-add.ts @@ -0,0 +1,41 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface BuddyAddRequest extends ProtocolRequest { + // 0n. 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface BuddyAddResponse extends ProtocolResponse { + // 0n. 사용자SEQ(n)... + userSeqs: number[]; +} + +export const encodeBuddyAdd: ProtocolEncoder = ( + req: BuddyAddRequest +) => { + const bodyList: PacketBody[] = []; + + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeBuddyAdd: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userSeqArray: number[] = [...message.bodyList]; + return { + userSeqs: userSeqArray + } as BuddyAddResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-del.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-del.ts new file mode 100644 index 00000000..d0860eef --- /dev/null +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-del.ts @@ -0,0 +1,41 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface BuddyDelRequest extends ProtocolRequest { + // 0n. 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface BuddyDelResponse extends ProtocolResponse { + // 0n. 사용자SEQ(n)... + userSeqs: number[]; +} + +export const encodeBuddyDel: ProtocolEncoder = ( + req: BuddyDelRequest +) => { + const bodyList: PacketBody[] = []; + + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeBuddyDel: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userSeqArray: number[] = [...message.bodyList]; + return { + userSeqs: userSeqArray + } as BuddyDelResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-update.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-update.ts new file mode 100644 index 00000000..66c7fa13 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-update.ts @@ -0,0 +1,47 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface BuddyUpdateRequest extends ProtocolRequest { + // 0. 사용자SEQ(n) + userSeq: number; + // 1. 즐겨찾기여부(y) + isFavorit: boolean; +} + +export interface BuddyUpdateResponse extends ProtocolResponse { + // 0. 사용자SEQ(n) + userSeq: number; + // 1. 즐겨찾기여부(y) + isFavorit: boolean; +} + +export const encodeBuddyUpdate: ProtocolEncoder = ( + req: BuddyUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.Integer, value: req.userSeq }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.isFavorit ? 'Y' : 'N' + }); + + return bodyList; +}; + +export const decodeBuddyUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + userSeq: message.bodyList[0], + isFavorit: message.bodyList[1] === 'Y' ? true : false + } as BuddyUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts index 2a0682d9..365fd17c 100644 --- a/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts @@ -1,8 +1,66 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; + +import { + SVC_TYPE_BUDDY, + SSVC_TYPE_BUDDY_ADD_REQ, + SSVC_TYPE_BUDDY_DEL_REQ, + SSVC_TYPE_BUDDY_UPD_REQ +} from '../types/service'; + +import { + BuddyAddRequest, + encodeBuddyAdd, + decodeBuddyAdd, + BuddyAddResponse +} from '../models/buddy-add'; +import { + BuddyDelRequest, + encodeBuddyDel, + decodeBuddyDel, + BuddyDelResponse +} from '../models/buddy-del'; +import { + BuddyUpdateRequest, + decodeBuddyUpdate, + encodeBuddyUpdate, + BuddyUpdateResponse +} from '../models/buddy-update'; + @Injectable({ providedIn: 'root' }) export class BuddyProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public buddyAdd(req: BuddyAddRequest): Observable { + return this.protocolService + .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeBuddyAdd(req)) + .pipe( + take(1), + map(res => decodeBuddyAdd(res)) + ); + } + + public buddyDel(req: BuddyDelRequest): Observable { + return this.protocolService + .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeBuddyDel(req)) + .pipe( + take(1), + map(res => decodeBuddyDel(res)) + ); + } + + public buddyUpdate(req: BuddyUpdateRequest): Observable { + return this.protocolService + .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeBuddyUpdate(req)) + .pipe( + take(1), + map(res => decodeBuddyUpdate(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/types/service.ts new file mode 100644 index 00000000..2574056b --- /dev/null +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/types/service.ts @@ -0,0 +1,7 @@ +export const SVC_TYPE_BUDDY = 4; // 동료 관리 +export const SSVC_TYPE_BUDDY_ADD_REQ = 1; // 동료추가 +export const SSVC_TYPE_BUDDY_ADD_RES = 2; +export const SSVC_TYPE_BUDDY_DEL_REQ = 11; // 동료삭제 +export const SSVC_TYPE_BUDDY_DEL_RES = 12; +export const SSVC_TYPE_BUDDY_UPD_REQ = 21; // 동료변경 +export const SSVC_TYPE_BUDDY_UPD_RES = 22; diff --git a/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts b/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts index 24173dd5..90da4389 100644 --- a/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts @@ -1,6 +1,9 @@ /* * Public API Surface of ucap-webmessenger-protocol-buddy */ +export * from './lib/models/buddy-add'; +export * from './lib/models/buddy-del'; +export * from './lib/models/buddy-update'; export * from './lib/services/buddy-protocol.service'; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/event-send.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/event-send.ts new file mode 100644 index 00000000..f3bca19c --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/event-send.ts @@ -0,0 +1,107 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + ProtocolStream, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; +import { EventType } from '../types/event.type'; +import { PushStatus } from '../types/pushStatus.type'; + +export interface EventSendRequest extends ProtocolRequest { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1. 이벤트타입(s) + type: EventType; + // 2. 이벤트내용(s) + sentMessage: string; +} + +export interface EventSendResponse { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + seq: number; + // 이벤트타입(s) + type: EventType; + // 발생일시(s) + sendDate: string; + // 이벤트내용(s) + message: string; + // 수신자수 + receiverCount: number; + // 알림상태(s) PC 경우에만 관여됨 N: 푸시를 보내지 않은 이벤트 S: 푸시를 보낸 이벤트 + pushStatus: PushStatus; + // 강퇴 타입(s) + ForcedExitType: string; + // 요청자 이름(s) + senderName: string; +} + +export interface EventSendNotification extends EventSendResponse { + // 대화방SEQ(s) + // 이벤트SEQ(n) + // 이벤트타입(s) + // 발생일시(s) + // 이벤트내용(s) + // 수신자수 + // 알림상태(s) PC 경우에만 관여됨 N: 푸시를 보내지 않은 이벤트 S: 푸시를 보낸 이벤트 + // 강퇴 타입(s) + // 요청자 이름(s) + + // 사용자아이디(s) + id?: string; + // 회사코드(s) + companyCode?: string; +} + +export const encodeEventSend: ProtocolEncoder = ( + req: EventSendRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.String, value: req.type }, + { type: PacketBodyValue.String, value: req.sentMessage } + ); + + return bodyList; +}; + +export const decodeEventSend: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + seq: message.bodyList[1], + type: message.bodyList[2] as EventType, + sendDate: message.bodyList[3], + message: message.bodyList[4], + receiverCount: message.bodyList[5] || 0, + pushStatus: message.bodyList[6] as PushStatus, + ForcedExitType: message.bodyList[7], + senderName: message.bodyList[8] + } as EventSendResponse; +}; + +export const decodeEventSendNotification: ProtocolDecoder< + EventSendNotification +> = (message: ProtocolMessage) => { + return { + roomSeq: message.bodyList[0], + seq: message.bodyList[1], + type: message.bodyList[2] as EventType, + sendDate: message.bodyList[3], + message: message.bodyList[4], + receiverCount: message.bodyList[5] || 0, + pushStatus: message.bodyList[6] as PushStatus, + ForcedExitType: message.bodyList[7], + senderName: message.bodyList[8], + id: message.bodyList[9], + companyCode: message.bodyList[10] + } as EventSendNotification; +}; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/services/event-protocol.service.ts b/projects/ucap-webmessenger-protocol-event/src/lib/services/event-protocol.service.ts index 73f11c46..08e9e6fe 100644 --- a/projects/ucap-webmessenger-protocol-event/src/lib/services/event-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-event/src/lib/services/event-protocol.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { map, takeWhile, timeout } from 'rxjs/operators'; +import { map, takeWhile, timeout, take } from 'rxjs/operators'; import { ProtocolService } from '@ucap-webmessenger/protocol'; @@ -17,8 +17,15 @@ import { SVC_TYPE_EVENT, SSVC_TYPE_EVENT_INFO_REQ, SSVC_TYPE_EVENT_INFO_RES, - SSVC_TYPE_EVENT_INFO_DATA + SSVC_TYPE_EVENT_INFO_DATA, + SSVC_TYPE_EVENT_SEND_REQ } from '../types/service'; +import { + EventSendRequest, + EventSendResponse, + decodeEventSend, + encodeEventSend +} from '../models/event-send'; @Injectable({ providedIn: 'root' @@ -39,4 +46,15 @@ export class EventProtocolService { }) ); } + + public eventSend(req: EventSendRequest): Observable { + return this.protocolService + .call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_SEND_REQ, ...encodeEventSend(req)) + .pipe( + take(1), + map(res => { + return decodeEventSend(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/types/pushStatus.type.ts b/projects/ucap-webmessenger-protocol-event/src/lib/types/pushStatus.type.ts new file mode 100644 index 00000000..81056b4a --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/types/pushStatus.type.ts @@ -0,0 +1,7 @@ +export enum PushStatus { + // PC 경우에만 관여됨 + // N: 푸시를 보내지 않은 이벤트 + NotSent = 'N', + // S: 푸시를 보낸 이벤트 + Sent = 'S' +} diff --git a/projects/ucap-webmessenger-protocol-event/src/public-api.ts b/projects/ucap-webmessenger-protocol-event/src/public-api.ts index d2ec1d13..6be7cdd3 100644 --- a/projects/ucap-webmessenger-protocol-event/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-event/src/public-api.ts @@ -5,3 +5,5 @@ export * from './lib/services/event-protocol.service'; export * from './lib/ucap-event-protocol.module'; + +export * from './lib/types/event.type'; diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-add.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-add.ts new file mode 100644 index 00000000..0a6a51e4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-add.ts @@ -0,0 +1,41 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface GroupAddRequest extends ProtocolRequest { + // 0. 동료그룹이름 + groupName: string; +} + +export interface GroupAddResponse extends ProtocolResponse { + // 0: 동료그룹SEQ(n) + groupSeq: number; + // 1: 동료그룹이름(s) + groupName: string; +} + +export const encodeGroupAdd: ProtocolEncoder = ( + req: GroupAddRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.groupName }); + + return bodyList; +}; + +export const decodeGroupAdd: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + groupSeq: message.bodyList[0], + groupName: message.bodyList[1] + } as GroupAddResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-del.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-del.ts new file mode 100644 index 00000000..1612aa6b --- /dev/null +++ b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-del.ts @@ -0,0 +1,38 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface GroupDelRequest extends ProtocolRequest { + // 0: 동료그룹SEQ(n) + groupSeq: number; +} + +export interface GroupDelResponse extends ProtocolResponse { + // 0: 동료그룹SEQ(n) + groupSeq: number; +} + +export const encodeGroupDel: ProtocolEncoder = ( + req: GroupDelRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.Integer, value: req.groupSeq }); + + return bodyList; +}; + +export const decodeGroupDel: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + groupSeq: message.bodyList[0] + } as GroupDelResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-update.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-update.ts new file mode 100644 index 00000000..996b5f5a --- /dev/null +++ b/projects/ucap-webmessenger-protocol-group/src/lib/models/group-update.ts @@ -0,0 +1,91 @@ +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface GroupUpdateRequest extends ProtocolRequest { + // 0: 동료그룹SEQ(n) + groupSeq: number; + // 1: 동료그룹이름(s) + groupName: string; + // 2n: 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface GroupUpdateResponse extends ProtocolResponse { + // 0: 동료그룹SEQ(n) + groupSeq: number; + // 1: 동료그룹이름(s) + groupName: string; + // 2n: 사용자SEQ(n)... + userSeqs: number[]; +} + +export const encodeGroupUpdate: ProtocolEncoder = ( + req: GroupUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.Integer, value: req.groupSeq }, + { type: PacketBodyValue.String, value: req.groupName }, + { type: PacketBodyValue.String, value: req.userSeqs.join(',') } + ); + + return bodyList; +}; + +export const decodeGroupUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + let userSeqArray: number[] = []; + if (message.bodyList.length > 2 && !message.bodyList[2].empty()) { + userSeqArray = message.bodyList[2].split(',').map((v: any) => Number(v)); + } + + return { + groupSeq: message.bodyList[0], + groupName: message.bodyList[1], + userSeqs: userSeqArray + } as GroupUpdateResponse; +}; + +export const encodeGroupUpdate2: ProtocolEncoder = ( + req: GroupUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.Integer, value: req.groupSeq }, + { type: PacketBodyValue.String, value: req.groupName } + ); + + if (req.userSeqs.length > 0) { + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + } + + return bodyList; +}; + +export const decodeGroupUpdate2: ProtocolDecoder = ( + message: ProtocolMessage +) => { + let userSeqArray: number[] = []; + if (message.bodyList.length > 2) { + userSeqArray = message.bodyList.slice(2); + } + + return { + groupSeq: message.bodyList[0], + groupName: message.bodyList[1], + userSeqs: userSeqArray + } as GroupUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts b/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts index 20714e3c..9649ad8a 100644 --- a/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts @@ -1,8 +1,81 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + GroupAddRequest, + encodeGroupAdd, + decodeGroupAdd, + GroupAddResponse +} from '../models/group-add'; +import { + SVC_TYPE_GROUP, + SSVC_TYPE_GROUP_ADD_REQ, + SSVC_TYPE_GROUP_DEL_REQ, + SSVC_TYPE_GROUP_UPD_REQ, + SSVC_TYPE_GROUP_UPD_REQ2 +} from '../types/service'; +import { + GroupDelRequest, + encodeGroupDel, + decodeGroupDel, + GroupDelResponse +} from '../models/group-del'; +import { + GroupUpdateRequest, + encodeGroupUpdate, + decodeGroupUpdate, + encodeGroupUpdate2, + decodeGroupUpdate2, + GroupUpdateResponse +} from '../models/group-update'; @Injectable({ providedIn: 'root' }) export class GroupProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public groupAdd(req: GroupAddRequest): Observable { + return this.protocolService + .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req)) + .pipe( + take(1), + map(res => decodeGroupAdd(res)) + ); + } + + public groupDel(req: GroupDelRequest): Observable { + return this.protocolService + .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req)) + .pipe( + take(1), + map(res => decodeGroupDel(res)) + ); + } + + public groupUpdate(req: GroupUpdateRequest): Observable { + return this.protocolService + .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req)) + .pipe( + take(1), + map(res => decodeGroupUpdate(res)) + ); + } + + public groupUpdate2( + req: GroupUpdateRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_GROUP, + SSVC_TYPE_GROUP_UPD_REQ2, + ...encodeGroupUpdate2(req) + ) + .pipe( + take(1), + map(res => decodeGroupUpdate2(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-group/src/lib/types/service.ts new file mode 100644 index 00000000..f986c8b2 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-group/src/lib/types/service.ts @@ -0,0 +1,9 @@ +export const SVC_TYPE_GROUP = 5; // 동료 그룹 관리 +export const SSVC_TYPE_GROUP_ADD_REQ = 1; // 동료 그룹 추가 +export const SSVC_TYPE_GROUP_ADD_RES = 2; +export const SSVC_TYPE_GROUP_DEL_REQ = 11; // 동료 그룹 삭제 +export const SSVC_TYPE_GROUP_DEL_RES = 12; +export const SSVC_TYPE_GROUP_UPD_REQ = 21; // 동료 그룹 변경 +export const SSVC_TYPE_GROUP_UPD_RES = 22; +export const SSVC_TYPE_GROUP_UPD_REQ2 = 23; +export const SSVC_TYPE_GROUP_UPD_RES2 = 24; diff --git a/projects/ucap-webmessenger-protocol-group/src/public-api.ts b/projects/ucap-webmessenger-protocol-group/src/public-api.ts index 210cf64d..766deaca 100644 --- a/projects/ucap-webmessenger-protocol-group/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-group/src/public-api.ts @@ -1,6 +1,9 @@ /* * Public API Surface of ucap-webmessenger-protocol-group */ +export * from './lib/models/group-add'; +export * from './lib/models/group-del'; +export * from './lib/models/group-update'; export * from './lib/services/group-protocol.service'; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts new file mode 100644 index 00000000..a9557f30 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts @@ -0,0 +1,302 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; +import { LocaleCode } from '@ucap-webmessenger/core'; +import { RoomType } from '../types/room.type'; +import { EventType } from '@ucap-webmessenger/protocol-event'; +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 + userSeq: number; + // 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 + userSeq: number; + // 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; + // 11. 참여 여부 <<<< + isJoinRoom: boolean; + // 12. 최종확인SEQ <<<< + 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; + // 25. CALL_MODE <<< + callMode: string; + // 26. 이용약관동의여부YN + isPrivacyAgree: boolean; + // 27. 유효접속여부YN + isValidLogin: boolean; + // 28. 임직원유형(s) + employeeType: EmployeeType; + // 29. 사용자아이디(s) <<< + id: string; +} + +export interface RoomInfoRequest extends ProtocolRequest { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1. 상세정보여부(y) + isDetail: boolean; + // 2. 언어코드(s) + localeCode: LocaleCode; +} + +export interface RoomInfoResponse extends ProtocolResponse { + // 0. 대화방SEQ(s) + roomSeq: string; +} + +export interface RoomInfoDataResponse extends ProtocolResponse { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1. {대화방정보} + roomInfo: RoomInfo; +} + +export interface RoomUserShortDataResponse extends ProtocolResponse { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1n. {참여자정보} + userInfos: UserInfoShort[]; +} +export interface RoomUserDataResponse extends ProtocolResponse { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1n. {참여자정보-D} + userInfos: UserInfo[]; +} + +export const encodeRoomInfo: ProtocolEncoder = ( + req: RoomInfoRequest +) => { + 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; +}; + +export const decodeRoomInfo: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0] + } as RoomInfoResponse; +}; + +export const decodeRoomInfoData: ProtocolDecoder = ( + 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], + 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], + roomInfo + } as RoomInfoDataResponse; +}; + +export const decodeRoomUserShortData: ProtocolDecoder< + RoomUserShortDataResponse +> = (message: ProtocolMessage) => { + const userInfos: UserInfoShort[] = []; + message.bodyList.slice(1).forEach(userInfo => { + const info = userInfo.split(BodyStringDivider); + userInfos.push({ + userSeq: info[0], + 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 RoomUserShortDataResponse; +}; + +export const decodeRoomUserData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const userInfos: UserInfo[] = []; + message.bodyList.slice(1).forEach(userInfo => { + const info = userInfo.split(BodyStringDivider); + userInfos.push({ + userSeq: info[0], + 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 RoomUserDataResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-invite.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-invite.ts new file mode 100644 index 00000000..8be64b05 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-invite.ts @@ -0,0 +1,50 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomInviteRequest extends ProtocolRequest { + // 0. 대화방SEQ(s) + roomSeq: string; + // 1n. 초대자 userSeq(n)... + inviteUserSeqs: number[]; +} + +export interface RoomInviteResponse extends ProtocolResponse { + // 0. 대화방SEQ(s) + roomSeq: string; +} + +export const encodeRoomInvite: ProtocolEncoder = ( + req: RoomInviteRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + for (const userSeq of req.inviteUserSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeRoomInvite: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0] + } as RoomInviteResponse; +}; + +export const decodeRoomInviteNotification: ProtocolDecoder< + RoomInviteResponse +> = (message: ProtocolMessage) => { + return { + roomSeq: message.bodyList[0] + } as RoomInviteResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts new file mode 100644 index 00000000..f3c334a3 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts @@ -0,0 +1,48 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomOpenRequest extends ProtocolRequest { + // 0. 구분자 + divCd: string; + // 1n. 초대자 userSeq(n)... + userSeqs: number[]; +} + +export interface RoomOpenResponse extends ProtocolResponse { + // 0. 구분자 + divCd: string; + // 1. 대화방SEQ(s) + roomSeq: string; + // 2. 신규여부(y) + newRoom: boolean; +} + +export const encodeRoomOpen: ProtocolEncoder = ( + req: RoomOpenRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeRoomOpen: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomSeq: message.bodyList[1], + newRoom: message.bodyList[2] === 'Y' ? true : false + } as RoomOpenResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts new file mode 100644 index 00000000..cc148195 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts @@ -0,0 +1,54 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomOpen2Request extends ProtocolRequest { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2n. 초대자 userSeq(n)... + userSeqs: number[]; +} + +export interface RoomOpen2Response extends ProtocolResponse { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2. 대화방SEQ(s) + roomSeq: string; + // 3. 신규여부(y) + newRoom: boolean; +} + +export const encodeRoomOpen2: ProtocolEncoder = ( + req: RoomOpen2Request +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); + bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() }); + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeRoomOpen2: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomName: message.bodyList[1], + roomSeq: message.bodyList[2], + newRoom: message.bodyList[3] === 'Y' ? true : false + } as RoomOpen2Response; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts new file mode 100644 index 00000000..ddf7d4bf --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts @@ -0,0 +1,72 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomOpen3Request extends ProtocolRequest { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2. 타이머대화방여부YN(s) + isTimerRoom: boolean; + // 3. 타이머시간(n) + timerRoomInterval: number; + // 4n. 초대자 userSeq(n)... + userSeqs: number[]; +} + +export interface RoomOpen3Response extends ProtocolResponse { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2. 대화방SEQ(s) + roomSeq: string; + // 3. 신규여부(y) + newRoom: boolean; + // 4. 타이머대화방여부YN(s) + isTimerRoom: boolean; + // 5. 타이머시간(n) + timerRoomInterval: number; +} + +export const encodeRoomOpen3: ProtocolEncoder = ( + req: RoomOpen3Request +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); + bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.isTimerRoom === true ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval + }); + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeRoomOpen3: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomName: message.bodyList[1], + roomSeq: message.bodyList[2], + newRoom: message.bodyList[3] === 'Y' ? true : false, + isTimerRoom: message.bodyList[4] === 'Y' ? true : false, + timerRoomInterval: message.bodyList[5] || 0 + } as RoomOpen3Response; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts new file mode 100644 index 00000000..35cf2da5 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts @@ -0,0 +1,73 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomOpen4Request extends ProtocolRequest { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2. 타이머대화방여부YN(s) + isTimerRoom: boolean; + // 3. 타이머시간(n) + timerRoomInterval: number; + // 4n. 초대자 userSeq(n)... + userSeqs: number[]; +} + +export interface RoomOpen4Response extends ProtocolResponse { + // 0. 구분자 + divCd: string; + // 1. 대화방제목(s) + roomName: string; + // 2. 대화방SEQ(s) + roomSeq: string; + // 3. 신규여부(y) + newRoom: boolean; + // 4. 타이머대화방여부YN(s) + isTimerRoom: boolean; + // 5. 타이머시간(n) + timerRoomInterval: number; +} + +export const encodeRoomOpen4: ProtocolEncoder = ( + req: RoomOpen4Request +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); + bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.isTimerRoom === true ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval + }); + for (const userSeq of req.userSeqs) { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + } + + return bodyList; +}; + +export const decodeRoomOpen4: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomName: message.bodyList[1], + roomSeq: message.bodyList[2], + newRoom: message.bodyList[3] === 'Y' ? true : false, + isTimerRoom: message.bodyList[4] === 'Y' ? true : false, + timerRoomInterval: + message.bodyList[4] !== 'Y' ? 0 : message.bodyList[5] || 0 + } as RoomOpen4Response; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts b/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts index d1d3542c..6ad5bc2b 100644 --- a/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts @@ -1,8 +1,139 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take, takeWhile } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_OPEN_REQ, + SSVC_TYPE_ROOM_OPEN2_REQ, + SSVC_TYPE_ROOM_OPEN3_REQ, + SSVC_TYPE_ROOM_OPEN4_REQ, + SSVC_TYPE_ROOM_INVITE_REQ, + SSVC_TYPE_ROOM_INFO_ROOM, + SSVC_TYPE_ROOM_INFO_RES, + SSVC_TYPE_ROOM_INFO_REQ, + SSVC_TYPE_ROOM_INFO_USER, + SSVC_TYPE_ROOM_INFO_USER2 +} from '../types/service'; +import { + RoomOpenRequest, + encodeRoomOpen, + decodeRoomOpen, + RoomOpenResponse +} from '../models/room-open'; +import { + RoomOpen2Request, + RoomOpen2Response, + decodeRoomOpen2, + encodeRoomOpen2 +} from '../models/room-open2'; +import { + RoomOpen3Request, + RoomOpen3Response, + encodeRoomOpen3, + decodeRoomOpen3 +} from '../models/room-open3'; +import { + RoomOpen4Request, + RoomOpen4Response, + encodeRoomOpen4, + decodeRoomOpen4 +} from '../models/room-open4'; +import { + RoomInviteRequest, + RoomInviteResponse, + encodeRoomInvite, + decodeRoomInvite +} from '../models/room-invite'; +import { + RoomInfoRequest, + RoomInfoResponse, + RoomInfoDataResponse, + RoomUserShortDataResponse, + RoomUserDataResponse, + encodeRoomInfo, + decodeRoomInfoData, + decodeRoomInfo, + decodeRoomUserShortData, + decodeRoomUserData +} from '../models/room-info'; + @Injectable({ providedIn: 'root' }) export class RoomProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public roomOpen(req: RoomOpenRequest): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeRoomOpen(req)) + .pipe( + take(1), + map(res => decodeRoomOpen(res)) + ); + } + + public roomOpen2(req: RoomOpen2Request): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req)) + .pipe( + take(1), + map(res => decodeRoomOpen2(res)) + ); + } + + public roomOpen3(req: RoomOpen3Request): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req)) + .pipe( + take(1), + map(res => decodeRoomOpen3(res)) + ); + } + + public roomOpen4(req: RoomOpen4Request): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req)) + .pipe( + take(1), + map(res => decodeRoomOpen4(res)) + ); + } + + public roomInvite(req: RoomInviteRequest): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INVITE_REQ, ...encodeRoomInvite(req)) + .pipe( + take(1), + map(res => decodeRoomInvite(res)) + ); + } + + public roomInfo( + req: RoomInfoRequest + ): Observable< + | RoomInfoResponse + | RoomInfoDataResponse + | RoomUserShortDataResponse + | RoomUserDataResponse + > { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INFO_REQ, ...encodeRoomInfo(req)) + .pipe( + takeWhile(res => SSVC_TYPE_ROOM_INFO_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_ROOM_INFO_ROOM === res.subServiceType) { + return decodeRoomInfoData(res); + } else if (SSVC_TYPE_ROOM_INFO_USER === res.subServiceType) { + return decodeRoomUserShortData(res); + } else if (SSVC_TYPE_ROOM_INFO_USER2 === res.subServiceType) { + return decodeRoomUserData(res); + } + + return decodeRoomInfo(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/types/employee.type.ts b/projects/ucap-webmessenger-protocol-room/src/lib/types/employee.type.ts new file mode 100644 index 00000000..1101c9ba --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/types/employee.type.ts @@ -0,0 +1,8 @@ +export enum EmployeeType { + // R(정규직) + Regular = 'R', + // P(파트너) + Partner = 'P', + // M(현장대리인) + Manager = 'M' +} diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts b/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts new file mode 100644 index 00000000..8c4e7b4e --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts @@ -0,0 +1,20 @@ +export enum RoomType { + // S: 1: 1 대화 + Single = 'S', + // M: 멀티대화 + Multi = 'M', + // B: Bot대화 + Bot = 'B', + // A: 알림방 + Allim = 'A', + + // // X: 확장대화 deprecated + // Extend = 'E', + // // N: 공지대화 deprecated + // Notice = 'N', + + // L: 링크(Legacy) + Link = 'L', + // K: MyTalk(나와의 대화) + Mytalk = 'K' +} diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-room/src/lib/types/service.ts new file mode 100644 index 00000000..b515ce14 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/types/service.ts @@ -0,0 +1,43 @@ +export const SVC_TYPE_ROOM = 10; // 대화방 +export const SSVC_TYPE_ROOM_OPEN_REQ = 1; // 대화방 개설 요청 +export const SSVC_TYPE_ROOM_OPEN_RES = 2; +export const SSVC_TYPE_ROOM_OPEN2_REQ = 3; // 대화방 개설 요청2 +export const SSVC_TYPE_ROOM_OPEN2_RES = 4; +export const SSVC_TYPE_ROOM_OPEN3_REQ = 5; // 대화방 개설 요청3 +export const SSVC_TYPE_ROOM_OPEN3_RES = 6; +export const SSVC_TYPE_ROOM_OPEN4_REQ = 7; // 대화방 개설 요청4 +export const SSVC_TYPE_ROOM_OPEN4_RES = 8; +export const SSVC_TYPE_ROOM_INVITE_REQ = 11; // 초대 요청 +export const SSVC_TYPE_ROOM_INVITE_RES = 12; +export const SSVC_TYPE_ROOM_INVITE_NOTI = 13; + +export const SSVC_TYPE_ROOM_INFO_REQ = 21; // 대화방 정보 요청 +export const SSVC_TYPE_ROOM_INFO_ROOM = 22; // 대화방 정보 +export const SSVC_TYPE_ROOM_INFO_USER = 23; // 참가자 정보 +export const SSVC_TYPE_ROOM_INFO_USER2 = 25; // 참가자 정보(상세) +export const SSVC_TYPE_ROOM_INFO_RES = 24; // 대화방 정보 완료 +export const SSVC_TYPE_ROOM_INFO_SIMPLE_REQ = 26; // 대화방 정보 요청 +// export const SSVC_TYPE_ROOM_INFO_ROOM = 22; // 대화방 정보 +// export const SSVC_TYPE_ROOM_INFO_USER = 25; // 참가자 정보(상세) +export const SSVC_TYPE_ROOM_INFO_SIMPLE_RES = 27; // 대화방 정보 완료 +export const SSVC_TYPE_ROOM_UPD_REQ = 31; // 대화방 변경 요청 +export const SSVC_TYPE_ROOM_UPD_RES = 32; +export const SSVC_TYPE_ROOM_INFO_UPD_REQ = 33; // 대화방 정보 변경 요청 +export const SSVC_TYPE_ROOM_INFO_UPD_RES = 34; // 대화방 정보 변경 응답 +export const SSVC_TYPE_ROOM_FONT_UPD_REQ = 35; // 대화방 옵션 변경 요청 +export const SSVC_TYPE_ROOM_FONT_UPD_NOTI = 36; // 대화방 옵션 변경 알림 +export const SSVC_TYPE_ROOM_FONT_UPD_RES = 37; // 대화방 옵션 변경 응답 +export const SSVC_TYPE_ROOM_DEL_REQ = 41; // 대화방 삭제 요청 +export const SSVC_TYPE_ROOM_DEL_RES = 42; +export const SSVC_TYPE_ROOM_EXIT_REQ = 51; // 퇴장 요청 +export const SSVC_TYPE_ROOM_EXIT_RES = 52; +export const SSVC_TYPE_ROOM_EXIT_NOTI = 53; + +export const SSVC_TYPE_ROOM_EXIT_ALL_REQ = 61; // 전체 대화방 퇴장 요청 +export const SSVC_TYPE_ROOM_EXIT_ALL_RES = 62; // 전체 대화방 퇴장 응답 + +export const SSVC_TYPE_ROOM_EXIT_FORCING_REQ = 54; // 대화상대 강퇴 요청 +export const SSVC_TYPE_ROOM_EXIT_FORCING_NOTI = 55; // 대화상대 강퇴 알림 +export const SSVC_TYPE_ROOM_EXIT_FORCING_RES = 56; // 대화상대 강퇴 응답 +export const SSVC_TYPE_ROOM_USER_STATUS_REQ = 71; // 대화상대 오프라인 체크 요청 +export const SSVC_TYPE_ROOM_USER_STATUS_RES = 72; // 대화상대 오프라인 체크 응답 diff --git a/projects/ucap-webmessenger-protocol-room/src/public-api.ts b/projects/ucap-webmessenger-protocol-room/src/public-api.ts index e3983287..70b64234 100644 --- a/projects/ucap-webmessenger-protocol-room/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-room/src/public-api.ts @@ -2,6 +2,15 @@ * Public API Surface of ucap-webmessenger-protocol-room */ +export * from './lib/models/room-info'; +export * from './lib/models/room-invite'; +export * from './lib/models/room-open'; +export * from './lib/models/room-open2'; +export * from './lib/models/room-open3'; +export * from './lib/models/room-open4'; + export * from './lib/services/room-protocol.service'; +export * from './lib/types/employee.type'; +export * from './lib/types/room.type'; export * from './lib/ucap-room-protocol.module'; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts new file mode 100644 index 00000000..81a428f0 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts @@ -0,0 +1,118 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; +import { UserInfo } from '../types/userInfo'; + +export interface BuddyInfo { + // 사용자SEQ + userSeq: number; + // 즐.찾 여부 + isFavorit: boolean; + // 친구여부 + isBuddy: boolean; +} + +export interface SyncBuddyRequest extends ProtocolRequest { + // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 + syncDate: string; +} + +export interface SyncBuddyDataResponse extends ProtocolResponse { + // n. {동료정보-S}... + buddyInfos: BuddyInfo[]; +} + +export interface SyncBuddyDataDetailResponse extends ProtocolResponse { + // n. {동료정보-S}... + buddyInfos: UserInfo[]; +} + +export interface SyncBuddyResponse extends ProtocolResponse { + // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 + syncDate: string; +} + +export const encodeSyncBuddy: ProtocolEncoder = ( + req: SyncBuddyRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' }); + return bodyList; +}; + +export const decodeSyncBuddy: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + syncDate: message.bodyList[0] + } as SyncBuddyResponse; +}; + +export const decodeSyncBuddyData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const buddyInfos: BuddyInfo[] = []; + message.bodyList.forEach(buddyinfo => { + const info = buddyinfo.split(BodyStringDivider); + buddyInfos.push({ + userSeq: info[0], + isFavorit: info[1] === 'Y' ? true : false, + isBuddy: info[2] === 'Y' ? true : false + }); + }); + return { + buddyInfos + } as SyncBuddyDataResponse; +}; + +export const decodeSyncBuddyDataDetail: ProtocolDecoder< + SyncBuddyDataDetailResponse +> = (message: ProtocolMessage) => { + const buddyInfos: UserInfo[] = []; + message.bodyList.forEach(buddyinfo => { + const info = buddyinfo.split(BodyStringDivider); + let i = 0; + buddyInfos.push({ + userSeq: 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++], + deptName: info[i++], + isFavorit: info[i++], + isBuddy: info[i++], + isActive: info[i++], + roleCd: info[i++], + 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++], + isValidLogin: info[i++], + employeeType: info[i++], + nickName: info[i++] + }); + }); + return { + buddyInfos + } as SyncBuddyDataDetailResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts new file mode 100644 index 00000000..ab767624 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts @@ -0,0 +1,101 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider +} from '@ucap-webmessenger/protocol'; + +export interface GroupInfo { + // 그룹SEQ(n) + seq: number; + // 그룹이름(s) + name: string; + // ActiveYN(s) + isActive: boolean; + // 사용자SEQ(s) + userSeqStr: string; +} +export interface SyncGroupRequest extends ProtocolRequest { + // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 + syncDate: string; +} + +export interface SyncGroupDataResponse extends ProtocolResponse { + // n. {동료그룹정보}... + groupInfos: GroupInfo[]; +} + +export interface SyncGroupDataDetailResponse extends ProtocolResponse { + // 그룹SEQ(n) + seq: number; + // 그룹이름(s) + name: string; + // ActiveYN(s) + isActive: boolean; + // 사용자SEQ(n)1 + userSeqs: number[]; +} + +export interface SyncGroupResponse extends ProtocolResponse { + // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 + syncDate: string; +} + +export const encodeSyncGroup: ProtocolEncoder = ( + req: SyncGroupRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' }); + return bodyList; +}; + +export const decodeSyncGroup: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + syncDate: message.bodyList[0] + } as SyncGroupResponse; +}; + +export const decodeSyncGroupData: ProtocolDecoder = ( + message: ProtocolMessage +) => { + const groupInfos: GroupInfo[] = []; + message.bodyList.forEach(buddyinfo => { + const info = buddyinfo.split(BodyStringDivider); + groupInfos.push({ + seq: info[0], + name: info[1], + isActive: info[2] === 'Y' ? true : false, + userSeqStr: info[3] + }); + }); + + return { + groupInfos + } as SyncGroupDataResponse; +}; + +export const decodeSyncGroupDataDetail: ProtocolDecoder< + SyncGroupDataDetailResponse +> = (message: ProtocolMessage) => { + let userSeqs: number[] = []; + if (message.bodyList.length > 3) { + userSeqs = message.bodyList.slice(3); + } + return { + // 그룹SEQ(n) + seq: message.bodyList[0], + // 그룹이름(s) + name: message.bodyList[1], + // ActiveYN(s) + isActive: message.bodyList[2] === 'Y' ? true : false, + // 사용자SEQ(n)1 + userSeqs + } as SyncGroupDataDetailResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts new file mode 100644 index 00000000..bcb18fa8 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts @@ -0,0 +1,175 @@ +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 = ( + 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 = ( + message: ProtocolMessage +) => { + return { + syncDate: message.bodyList[0] + } as SyncRoomResponse; +}; + +export const decodeSyncRoomData: ProtocolDecoder = ( + 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({ + userSeq: info[0], + 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({ + userSeq: info[0], + 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; +}; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts index 65bbd034..ff96c854 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts @@ -1,8 +1,211 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, take, takeWhile } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + SyncBuddyRequest, + SyncBuddyResponse, + SyncBuddyDataResponse, + encodeSyncBuddy, + decodeSyncBuddyData, + decodeSyncBuddy, + decodeSyncBuddyDataDetail +} from '../models/buddy'; +import { + SVC_TYPE_SYNC_BUDDY, + SSVC_TYPE_SYNC_BUDDY_REQ, + SSVC_TYPE_SYNC_BUDDY_RES, + SSVC_TYPE_SYNC_BUDDY_DATA, + SSVC_TYPE_SYNC_BUDDY2_REQ, + SSVC_TYPE_SYNC_BUDDY2_RES, + SSVC_TYPE_SYNC_BUDDY2_DATA, + SVC_TYPE_SYNC_GROUP, + SSVC_TYPE_SYNC_GROUP_REQ, + SSVC_TYPE_SYNC_GROUP_RES, + SSVC_TYPE_SYNC_GROUP_DATA, + SSVC_TYPE_SYNC_GROUP_REQ2, + SSVC_TYPE_SYNC_GROUP_RES2, + SSVC_TYPE_SYNC_GROUP_DATA2, + SVC_TYPE_SYNC_ROOM, + SSVC_TYPE_SYNC_ROOM_REQ, + SSVC_TYPE_SYNC_ROOM_RES, + SSVC_TYPE_SYNC_ROOM_DATA, + SSVC_TYPE_SYNC_ROOM_USER, + SSVC_TYPE_SYNC_ROOM_USER2, + SSVC_TYPE_SYNC_ROOM2_REQ, + SSVC_TYPE_SYNC_ROOM2_RES, + SSVC_TYPE_SYNC_ROOM2_DATA, + SSVC_TYPE_SYNC_ROOM2_USER, + SSVC_TYPE_SYNC_ROOM2_USER2 +} from '../types/service'; +import { + SyncGroupRequest, + SyncGroupResponse, + SyncGroupDataResponse, + encodeSyncGroup, + decodeSyncGroupDataDetail, + decodeSyncGroup, + decodeSyncGroupData, + SyncGroupDataDetailResponse +} from '../models/group'; +import { + SyncRoomRequest, + SyncRoomResponse, + encodeSyncRoom, + decodeSyncRoom, + SyncRoomUserDataResponse, + SyncRoomUserDataDetailResponse, + SyncRoomDataResponse, + decodeSyncRoomData, + decodeSyncRoomUserData, + decodeSyncRoomUserDataDetail +} from '../models/room'; + @Injectable({ providedIn: 'root' }) export class SyncProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public syncBuddy( + req: SyncBuddyRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_SYNC_BUDDY, + SSVC_TYPE_SYNC_BUDDY_REQ, + ...encodeSyncBuddy(req) + ) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) { + return decodeSyncBuddyData(res); + } + + return decodeSyncBuddy(res); + }) + ); + } + + public syncBuddy2( + req: SyncBuddyRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_SYNC_BUDDY, + SSVC_TYPE_SYNC_BUDDY2_REQ, + ...encodeSyncBuddy(req) + ) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_BUDDY2_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) { + return decodeSyncBuddyDataDetail(res); + } + + return decodeSyncBuddy(res); + }) + ); + } + + public syncGroup( + req: SyncGroupRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_SYNC_GROUP, + SSVC_TYPE_SYNC_GROUP_REQ, + ...encodeSyncGroup(req) + ) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) { + return decodeSyncGroupData(res); + } + + return decodeSyncGroup(res); + }) + ); + } + + public syncGroup2( + req: SyncGroupRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_SYNC_GROUP, + SSVC_TYPE_SYNC_GROUP_REQ2, + ...encodeSyncGroup(req) + ) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES2 !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) { + return decodeSyncGroupDataDetail(res); + } + + return decodeSyncGroup(res); + }) + ); + } + + public syncRoom( + req: SyncRoomRequest + ): Observable< + | SyncRoomResponse + | SyncRoomDataResponse + | SyncRoomUserDataResponse + | SyncRoomUserDataDetailResponse + > { + return this.protocolService + .call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeSyncRoom(req)) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) { + return decodeSyncRoomData(res); + } else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) { + return decodeSyncRoomUserData(res); + } else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) { + return decodeSyncRoomUserDataDetail(res); + } + + return decodeSyncRoom(res); + }) + ); + } + + public syncRoom2( + req: SyncRoomRequest + ): Observable< + | SyncRoomResponse + | SyncRoomDataResponse + | SyncRoomUserDataResponse + | SyncRoomUserDataDetailResponse + > { + return this.protocolService + .call( + SVC_TYPE_SYNC_ROOM, + SSVC_TYPE_SYNC_ROOM2_REQ, + ...encodeSyncRoom(req) + ) + .pipe( + takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType), + map(res => { + if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) { + return decodeSyncRoomData(res); + } else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) { + return decodeSyncRoomUserData(res); + } else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) { + return decodeSyncRoomUserDataDetail(res); + } + + return decodeSyncRoom(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/types/service.ts new file mode 100644 index 00000000..c13fddf2 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/types/service.ts @@ -0,0 +1,27 @@ +export const SVC_TYPE_SYNC_BUDDY = 81; // 동료 씽크 +export const SSVC_TYPE_SYNC_BUDDY_REQ = 1; // 동료목록 씽크 요청 +export const SSVC_TYPE_SYNC_BUDDY_DATA = 2; // 동료목록 Data +export const SSVC_TYPE_SYNC_BUDDY_RES = 3; // 동료목록 씽크 완료 +export const SSVC_TYPE_SYNC_BUDDY2_REQ = 11; // 동료목록 씽크 요청(상세) +export const SSVC_TYPE_SYNC_BUDDY2_DATA = 12; // 동료 정보 Data(상세) +export const SSVC_TYPE_SYNC_BUDDY2_RES = 13; // 동료 정보 쿼리 완료(상세) + +export const SVC_TYPE_SYNC_GROUP = 82; // 동료 씽크 +export const SSVC_TYPE_SYNC_GROUP_REQ = 1; // 그룹목록 씽크 요청 +export const SSVC_TYPE_SYNC_GROUP_DATA = 2; // 그룹 Data +export const SSVC_TYPE_SYNC_GROUP_RES = 3; // 그룹목록 씽크 완료 +export const SSVC_TYPE_SYNC_GROUP_REQ2 = 4; // 그룹목록 씽크 요청 +export const SSVC_TYPE_SYNC_GROUP_DATA2 = 5; // 그룹 Data +export const SSVC_TYPE_SYNC_GROUP_RES2 = 6; // 그룹목록 씽크 완료 + +export const SVC_TYPE_SYNC_ROOM = 83; // 대화방 씽크 +export const SSVC_TYPE_SYNC_ROOM_REQ = 1; // 대화방 목록 씽크 요청 +export const SSVC_TYPE_SYNC_ROOM_DATA = 2; // 대화방 목록 Data +export const SSVC_TYPE_SYNC_ROOM_USER = 3; // 참여 정보(방갯수만큼) +export const SSVC_TYPE_SYNC_ROOM_USER2 = 5; // 참여 정보(방갯수만큼) +export const SSVC_TYPE_SYNC_ROOM_RES = 4; // 대화방 목록 씽크 완료 +export const SSVC_TYPE_SYNC_ROOM2_REQ = 11; // 대화방 목록 씽크 요청 +export const SSVC_TYPE_SYNC_ROOM2_DATA = 12; // 대화방 목록 Data +export const SSVC_TYPE_SYNC_ROOM2_USER = 13; // 참여 정보(방갯수만큼) +export const SSVC_TYPE_SYNC_ROOM2_USER2 = 15; // 참여 정보(방갯수만큼) +export const SSVC_TYPE_SYNC_ROOM2_RES = 14; // 대화방 목록 씽크 완료 diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/types/userInfo.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/types/userInfo.ts new file mode 100644 index 00000000..03cfee48 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/types/userInfo.ts @@ -0,0 +1,63 @@ +import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; +import { EmployeeType } from '@ucap-webmessenger/protocol-room'; + +export interface UserInfo { + // 사용자SEQ + userSeq: 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; +} diff --git a/projects/ucap-webmessenger-protocol-sync/src/public-api.ts b/projects/ucap-webmessenger-protocol-sync/src/public-api.ts index f98e4736..317de0a3 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/public-api.ts @@ -1,7 +1,11 @@ /* * Public API Surface of ucap-webmessenger-protocol-sync */ +export * from './lib/models/buddy'; +export * from './lib/models/group'; export * from './lib/services/sync-protocol.service'; export * from './lib/ucap-sync-protocol.module'; + +export * from './lib/types/userInfo'; diff --git a/projects/ucap-webmessenger-protocol/src/lib/types/packet-body-divider.ts b/projects/ucap-webmessenger-protocol/src/lib/types/packet-body-divider.ts index 83b7fa4d..7c91f980 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/types/packet-body-divider.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/types/packet-body-divider.ts @@ -1,2 +1,4 @@ export const PacketBodyDivider = '\f'; export const PacketBodyValueDivider = '\t'; + +export const BodyStringDivider = '\b';