From 9473730d949771871146861d35e0c10879944681 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Wed, 25 Sep 2019 11:47:51 +0900 Subject: [PATCH] option protocol is implemented --- .../src/app/app.module.ts | 2 + .../src/lib/type/call-alarm.type.ts | 5 + .../src/lib/type/call-forward.type.ts | 5 + .../src/lib/type/call-mode.type.ts | 5 + .../src/lib/type/caller-type.type.ts | 4 + .../src/lib/type/notification-method.type.ts | 5 + .../ucap-webmessenger-core/src/public-api.ts | 5 + .../src/lib/models/call-update.ts | 137 ++++++++++++++++ .../src/lib/models/call-view.ts | 68 ++++++++ .../src/lib/models/reg-update.ts | 153 ++++++++++++++++++ .../src/lib/models/reg-view.ts | 70 ++++++++ .../src/lib/models/update.ts | 68 ++++++++ .../src/lib/models/view.ts | 39 +++++ .../lib/services/option-protocol.service.ts | 122 +++++++++++++- .../src/lib/types/service.ts | 18 +++ .../src/public-api.ts | 7 + 16 files changed, 712 insertions(+), 1 deletion(-) create mode 100644 projects/ucap-webmessenger-core/src/lib/type/call-alarm.type.ts create mode 100644 projects/ucap-webmessenger-core/src/lib/type/call-forward.type.ts create mode 100644 projects/ucap-webmessenger-core/src/lib/type/call-mode.type.ts create mode 100644 projects/ucap-webmessenger-core/src/lib/type/caller-type.type.ts create mode 100644 projects/ucap-webmessenger-core/src/lib/type/notification-method.type.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/call-update.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/call-view.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/reg-update.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/reg-view.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/update.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/models/view.ts create mode 100644 projects/ucap-webmessenger-protocol-option/src/lib/types/service.ts diff --git a/projects/ucap-webmessenger-app/src/app/app.module.ts b/projects/ucap-webmessenger-app/src/app/app.module.ts index 20b54c1d..9d94a3ed 100644 --- a/projects/ucap-webmessenger-app/src/app/app.module.ts +++ b/projects/ucap-webmessenger-app/src/app/app.module.ts @@ -14,6 +14,7 @@ import { UCapPiModule } from '@ucap-webmessenger/pi'; import { UCapProtocolModule } from '@ucap-webmessenger/protocol'; import { UCapAuthenticationProtocolModule } from '@ucap-webmessenger/protocol-authentication'; import { UCapInnerProtocolModule } from '@ucap-webmessenger/protocol-inner'; +import { UCapOptionProtocolModule } from '@ucap-webmessenger/protocol-option'; import { UCapUiModule } from '@ucap-webmessenger/ui'; import { UCapUiAccountModule } from '@ucap-webmessenger/ui-account'; @@ -62,6 +63,7 @@ import { GUARDS } from './guards'; }), UCapAuthenticationProtocolModule.forRoot(), UCapInnerProtocolModule.forRoot(), + UCapOptionProtocolModule.forRoot(), UCapUiModule.forRoot(), UCapUiAccountModule.forRoot(), diff --git a/projects/ucap-webmessenger-core/src/lib/type/call-alarm.type.ts b/projects/ucap-webmessenger-core/src/lib/type/call-alarm.type.ts new file mode 100644 index 00000000..7cc0286e --- /dev/null +++ b/projects/ucap-webmessenger-core/src/lib/type/call-alarm.type.ts @@ -0,0 +1,5 @@ +export enum CallAlarmType { + Always = 'A', + OnlyOnce = 'B', + None = 'N' +} diff --git a/projects/ucap-webmessenger-core/src/lib/type/call-forward.type.ts b/projects/ucap-webmessenger-core/src/lib/type/call-forward.type.ts new file mode 100644 index 00000000..e07ad589 --- /dev/null +++ b/projects/ucap-webmessenger-core/src/lib/type/call-forward.type.ts @@ -0,0 +1,5 @@ +export enum CallForwardType { + Always = 'A', + MissedCall = 'B', + None = 'N' +} diff --git a/projects/ucap-webmessenger-core/src/lib/type/call-mode.type.ts b/projects/ucap-webmessenger-core/src/lib/type/call-mode.type.ts new file mode 100644 index 00000000..ab2754c1 --- /dev/null +++ b/projects/ucap-webmessenger-core/src/lib/type/call-mode.type.ts @@ -0,0 +1,5 @@ +export enum CallMode { + C2C = 'C', + FMC = 'F', + NativeCall = 'N' +} diff --git a/projects/ucap-webmessenger-core/src/lib/type/caller-type.type.ts b/projects/ucap-webmessenger-core/src/lib/type/caller-type.type.ts new file mode 100644 index 00000000..928955f9 --- /dev/null +++ b/projects/ucap-webmessenger-core/src/lib/type/caller-type.type.ts @@ -0,0 +1,4 @@ +export enum CallerType { + Line = 'L', + Handphone = 'H' +} diff --git a/projects/ucap-webmessenger-core/src/lib/type/notification-method.type.ts b/projects/ucap-webmessenger-core/src/lib/type/notification-method.type.ts new file mode 100644 index 00000000..92806d37 --- /dev/null +++ b/projects/ucap-webmessenger-core/src/lib/type/notification-method.type.ts @@ -0,0 +1,5 @@ +export enum NotificationMethod { + Sound = 0, + Alert = 1, + SoundAndAlert = 2 +} diff --git a/projects/ucap-webmessenger-core/src/public-api.ts b/projects/ucap-webmessenger-core/src/public-api.ts index 27d44e5c..1efbf2fe 100644 --- a/projects/ucap-webmessenger-core/src/public-api.ts +++ b/projects/ucap-webmessenger-core/src/public-api.ts @@ -3,9 +3,14 @@ */ export * from './lib/type/app-type.type'; +export * from './lib/type/call-alarm.type'; +export * from './lib/type/call-forward.type'; +export * from './lib/type/call-mode.type'; +export * from './lib/type/caller-type.type'; export * from './lib/type/device-devision.type'; export * from './lib/type/device-type.type'; export * from './lib/type/locale-code.type'; +export * from './lib/type/notification-method.type'; export * from './lib/type/push-type.type'; export * from './lib/type/status-code.type'; export * from './lib/type/status-type.type'; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/call-update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/call-update.ts new file mode 100644 index 00000000..dfb34efa --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/call-update.ts @@ -0,0 +1,137 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; +import { + CallerType, + CallMode, + CallAlarmType, + CallForwardType +} from '@ucap-webmessenger/core'; + +// tslint:disable-next-line: no-empty-interface +export interface CallUpdateRequest extends ProtocolRequest { + // 0 IPPhoneYN(s) + useIpPhone: boolean; + // 1 CallerType(s) + callerType: CallerType; + // 2 CallMode(s) + callMode: CallMode; + // 3 PairingYN(s) + usePairing: boolean; + // 4 CallAlarmYN(s) + useCallAlarm: boolean; + // 5 CallAlarmType(s) + callAlarmType: CallAlarmType; + // 6 CallForwardType(s) + callForwardType: CallForwardType; + // 7 대표착신번호(s) + representativeCalledNumber: string; + // 8 착신번호(s)1 + calledNumber1: string; + // 9 착신번호(s)2 + calledNumber2: string; + // 10 착신번호(s)3 + calledNumber3: string; +} + +export interface CallUpdateResponse extends ProtocolResponse { + // 0 IPPhoneYN(s) + useIpPhone?: boolean; + // 1 CallerType(s) + callerType?: CallerType; + // 2 CallMode(s) + callMode?: CallMode; + // 3 PairingYN(s) + usePairing?: boolean; + // 4 CallAlarmYN(s) + useCallAlarm?: boolean; + // 5 CallAlarmType(s) + callAlarmType?: CallAlarmType; + // 6 CallForwardType(s) + callForwardType?: CallForwardType; + // 7 대표착신번호(s) + representativeCalledNumber?: string; + // 8 착신번호(s)1 + calledNumber1?: string; + // 9 착신번호(s)2 + calledNumber2?: string; + // 10 착신번호(s)3 + calledNumber3?: string; +} + +export const encodeCallUpdate: ProtocolEncoder = ( + req: CallUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ + type: PacketBodyValue.String, + value: req.useIpPhone ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.callerType + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.callMode + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.usePairing ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.useCallAlarm ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.callAlarmType + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.callForwardType + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.representativeCalledNumber + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.calledNumber1 + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.calledNumber2 + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.calledNumber3 + }); + + return bodyList; +}; + +export const decodeCallUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + useIpPhone: message.bodyList[0] === 'Y' ? true : false, + callerType: message.bodyList[1] as CallerType, + callMode: message.bodyList[2] as CallMode, + usePairing: message.bodyList[3] === 'Y' ? true : false, + useCallAlarm: message.bodyList[4] === 'Y' ? true : false, + callAlarmType: message.bodyList[5] as CallAlarmType, + callForwardType: message.bodyList[6] as CallForwardType, + representativeCalledNumber: message.bodyList[7], + calledNumber1: message.bodyList[8], + calledNumber2: message.bodyList[9], + calledNumber3: message.bodyList[10] + } as CallUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/call-view.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/call-view.ts new file mode 100644 index 00000000..47eff796 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/call-view.ts @@ -0,0 +1,68 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; +import { + CallerType, + CallMode, + CallAlarmType, + CallForwardType +} from '@ucap-webmessenger/core'; + +// tslint:disable-next-line: no-empty-interface +export interface CallViewRequest extends ProtocolRequest {} + +export interface CallViewResponse extends ProtocolResponse { + // 0 IPPhoneYN(s) + useIpPhone?: boolean; + // 1 CallerType(s) + callerType?: CallerType; + // 2 CallMode(s) + callMode?: CallMode; + // 3 PairingYN(s) + usePairing?: boolean; + // 4 CallAlarmYN(s) + useCallAlarm?: boolean; + // 5 CallAlarmType(s) + callAlarmType?: CallAlarmType; + // 6 CallForwardType(s) + callForwardType?: CallForwardType; + // 7 대표착신번호(s) + representativeCalledNumber?: string; + // 8 착신번호(s)1 + calledNumber1?: string; + // 9 착신번호(s)2 + calledNumber2?: string; + // 10 착신번호(s)3 + calledNumber3?: string; +} + +export const encodeCallView: ProtocolEncoder = ( + req: CallViewRequest +) => { + const bodyList: PacketBody[] = []; + + return bodyList; +}; + +export const decodeCallView: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + useIpPhone: message.bodyList[0] === 'Y' ? true : false, + callerType: message.bodyList[1] as CallerType, + callMode: message.bodyList[2] as CallMode, + usePairing: message.bodyList[3] === 'Y' ? true : false, + useCallAlarm: message.bodyList[4] === 'Y' ? true : false, + callAlarmType: message.bodyList[5] as CallAlarmType, + callForwardType: message.bodyList[6] as CallForwardType, + representativeCalledNumber: message.bodyList[7], + calledNumber1: message.bodyList[8], + calledNumber2: message.bodyList[9], + calledNumber3: message.bodyList[10] + } as CallViewResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-update.ts new file mode 100644 index 00000000..ab69df7f --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-update.ts @@ -0,0 +1,153 @@ +import { NotificationMethod, DeviceType } from '@ucap-webmessenger/core'; + +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; + +// tslint:disable-next-line: no-empty-interface +export interface RegUpdateRequest extends ProtocolRequest { + // 0 알림방법(n) + notificationMethod: NotificationMethod; + // 1 모바일알림(n) + mobileNotification: number; + // 2 폰트종류(s) + fontFamily: string; + // 3 폰트크기(n) + fontSize: number; + // 4 알림받음/받지않음(n) + receiveNotification: number; + // 5 알림방법(n) + notificationMethod0: number; + // 6 알림창 설정(n) + notificationExposureTime: number; + // 7 타임존(s) + timeZone: string; + // 8 타임존값(s) + timeZoneValue: string; + // 9 부재중시간설정(n) + absenceTime: number; + // 10 메뉴 언어(n) + menuLanguage: number; + // 11 인사정보 언어(n) + hrInformationLanguage: number; + deviceType: DeviceType; +} + +export interface RegUpdateResponse extends ProtocolResponse { + // 0 알림방법(n) + notificationMethod?: NotificationMethod; + // 1 모바일알림(n) + mobileNotification?: number; + // 2 폰트종류(s) + fontFamily?: string; + // 3 폰트크기(n) + fontSize?: number; + // 4 알림받음/받지않음(n) + receiveNotification?: number; + // 5 알림방법(n) + notificationMethod0?: number; + // 6 알림창 설정(n) + notificationExposureTime?: number; + // 7 타임존(s) + timeZone?: string; + // 8 타임존값(s) + timeZoneValue?: string; + // 9 부재중시간설정(n) + absenceTime?: number; + // 10 메뉴 언어(n) + menuLanguage?: number; + // 11 인사정보 언어(n) + hrInformationLanguage?: number; + // 12 단말타입(s) + deviceType?: DeviceType; + // 13 번역키 + translationKey?: string; +} + +export const encodeRegUpdate: ProtocolEncoder = ( + req: RegUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.notificationMethod + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.mobileNotification + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.fontFamily + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.fontSize + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.receiveNotification + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.notificationMethod0 + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.notificationExposureTime + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.timeZone + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.timeZoneValue + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.absenceTime + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.menuLanguage + }); + bodyList.push({ + type: PacketBodyValue.Integer, + value: req.hrInformationLanguage + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.deviceType + }); + + return bodyList; +}; + +export const decodeRegUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + notificationMethod: message.bodyList[0] as NotificationMethod, + mobileNotification: message.bodyList[1], + fontFamily: message.bodyList[2], + fontSize: message.bodyList[3], + receiveNotification: message.bodyList[4], + notificationMethod0: message.bodyList[5], + notificationExposureTime: message.bodyList[6], + timeZone: message.bodyList[7], + timeZoneValue: message.bodyList[8], + absenceTime: message.bodyList[9], + menuLanguage: message.bodyList[10], + hrInformationLanguage: message.bodyList[11], + deviceType: message.bodyList[12], + translationKey: message.bodyList[13] + } as RegUpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-view.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-view.ts new file mode 100644 index 00000000..8348b916 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/reg-view.ts @@ -0,0 +1,70 @@ +import { NotificationMethod } from '@ucap-webmessenger/core'; + +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +// tslint:disable-next-line: no-empty-interface +export interface RegViewRequest extends ProtocolRequest {} + +export interface RegViewResponse extends ProtocolResponse { + // 0 알림방법(n) + notificationMethod?: NotificationMethod; + // 1 모바일알림(n) + mobileNotification?: number; + // 2 폰트종류(s) + fontFamily?: string; + // 3 폰트크기(n) + fontSize?: number; + // 4 알림받음/받지않음(n) + receiveNotification?: number; + // 5 알림방법(n) + notificationMethod0?: number; + // 6 알림창 설정(n) + notificationExposureTime?: number; + // 7 타임존(s) + timeZone?: string; + // 8 타임존값(s) + timeZoneValue?: string; + // 9 부재중시간설정(n) + absenceTime?: number; + // 10 메뉴 언어(n) + menuLanguage?: number; + // 11 인사정보 언어(n) + hrInformationLanguage?: number; + // 12 번역키 + translationKey?: string; +} + +export const encodeRegView: ProtocolEncoder = ( + req: RegViewRequest +) => { + const bodyList: PacketBody[] = []; + + return bodyList; +}; + +export const decodeRegView: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + notificationMethod: message.bodyList[0] as NotificationMethod, + mobileNotification: message.bodyList[1], + fontFamily: message.bodyList[2], + fontSize: message.bodyList[3], + receiveNotification: message.bodyList[4], + notificationMethod0: message.bodyList[5], + notificationExposureTime: message.bodyList[6], + timeZone: message.bodyList[7], + timeZoneValue: message.bodyList[8], + absenceTime: message.bodyList[9], + menuLanguage: message.bodyList[10], + hrInformationLanguage: message.bodyList[11], + translationKey: message.bodyList[12] + } as RegViewResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/update.ts new file mode 100644 index 00000000..b6646199 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/update.ts @@ -0,0 +1,68 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; + +// tslint:disable-next-line: no-empty-interface +export interface UpdateRequest extends ProtocolRequest { + // 알람여부(y) + receiveAlarm: boolean; + // 알람VIEW여부(y) + displayAlarm: boolean; + // 그룹알람여부(y) + receiveGroupAlarm: boolean; + // PC알람여부(y) + receivePcAlarm: boolean; +} + +export interface UpdateResponse extends ProtocolResponse { + // 알람여부(y) + receiveAlarm?: boolean; + // 알람VIEW여부(y) + displayAlarm?: boolean; + // 그룹알람여부(y) + receiveGroupAlarm?: boolean; + // PC알람여부(y) + receivePcAlarm?: boolean; +} + +export const encodeUpdate: ProtocolEncoder = ( + req: UpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ + type: PacketBodyValue.String, + value: req.receiveAlarm ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.displayAlarm ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.receiveGroupAlarm ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.receivePcAlarm ? 'Y' : 'N' + }); + + return bodyList; +}; + +export const decodeUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + receiveAlarm: message.bodyList[0] === 'Y' ? true : false, + displayAlarm: message.bodyList[1] === 'Y' ? true : false, + receiveGroupAlarm: message.bodyList[2] === 'Y' ? true : false, + receivePcAlarm: message.bodyList[3] === 'Y' ? true : false + } as UpdateResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/models/view.ts b/projects/ucap-webmessenger-protocol-option/src/lib/models/view.ts new file mode 100644 index 00000000..d233718a --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/models/view.ts @@ -0,0 +1,39 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +// tslint:disable-next-line: no-empty-interface +export interface ViewRequest extends ProtocolRequest {} + +export interface ViewResponse extends ProtocolResponse { + // 알람여부(y) + receiveAlarm?: boolean; + // 알람VIEW여부(y) + displayAlarm?: boolean; + // 그룹알람여부(y) + receiveGroupAlarm?: boolean; + // PC알람여부(y) + receivePcAlarm?: boolean; +} + +export const encodeView: ProtocolEncoder = (req: ViewRequest) => { + const bodyList: PacketBody[] = []; + + return bodyList; +}; + +export const decodeView: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + receiveAlarm: message.bodyList[0] === 'Y' ? true : false, + displayAlarm: message.bodyList[1] === 'Y' ? true : false, + receiveGroupAlarm: message.bodyList[2] === 'Y' ? true : false, + receivePcAlarm: message.bodyList[3] === 'Y' ? true : false + } as ViewResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts b/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts index 256e68dd..99d10f05 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/services/option-protocol.service.ts @@ -1,8 +1,128 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { take, map } from 'rxjs/operators'; + +import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { + SVC_TYPE_OPTION, + SSVC_TYPE_OPTION_VIEW_REQ, + SSVC_TYPE_OPTION_UPD_REQ, + SSVC_TYPE_OPTION_REG_VIEW_REQ, + SSVC_TYPE_OPTION_REG_UPD_REQ, + SSVC_TYPE_OPTION_CALL_VIEW_REQ, + SSVC_TYPE_OPTION_CALL_UPD_REQ +} from '../types/service'; +import { + encodeView, + decodeView, + ViewRequest, + ViewResponse +} from '../models/view'; +import { + UpdateRequest, + UpdateResponse, + encodeUpdate, + decodeUpdate +} from '../models/update'; +import { + RegViewRequest, + RegViewResponse, + encodeRegView, + decodeRegView +} from '../models/reg-view'; +import { + RegUpdateRequest, + RegUpdateResponse, + encodeRegUpdate, + decodeRegUpdate +} from '../models/reg-update'; +import { + CallViewRequest, + CallViewResponse, + encodeCallView, + decodeCallView +} from '../models/call-view'; +import { + CallUpdateRequest, + CallUpdateResponse, + encodeCallUpdate, + decodeCallUpdate +} from '../models/call-update'; + @Injectable({ providedIn: 'root' }) export class OptionProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public view(req: ViewRequest): Observable { + return this.protocolService + .call(SVC_TYPE_OPTION, SSVC_TYPE_OPTION_VIEW_REQ, ...encodeView(req)) + .pipe( + take(1), + map(res => decodeView(res)) + ); + } + + public update(req: UpdateRequest): Observable { + return this.protocolService + .call(SVC_TYPE_OPTION, SSVC_TYPE_OPTION_UPD_REQ, ...encodeUpdate(req)) + .pipe( + take(1), + map(res => decodeUpdate(res)) + ); + } + + public regView(req: RegViewRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_OPTION, + SSVC_TYPE_OPTION_REG_VIEW_REQ, + ...encodeRegView(req) + ) + .pipe( + take(1), + map(res => decodeRegView(res)) + ); + } + + public regUpdate(req: RegUpdateRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_OPTION, + SSVC_TYPE_OPTION_REG_UPD_REQ, + ...encodeRegUpdate(req) + ) + .pipe( + take(1), + map(res => decodeRegUpdate(res)) + ); + } + + public callView(req: CallViewRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_OPTION, + SSVC_TYPE_OPTION_CALL_VIEW_REQ, + ...encodeCallView(req) + ) + .pipe( + take(1), + map(res => decodeCallView(res)) + ); + } + + public callUpdate(req: CallUpdateRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_OPTION, + SSVC_TYPE_OPTION_CALL_UPD_REQ, + ...encodeCallUpdate(req) + ) + .pipe( + take(1), + map(res => decodeCallUpdate(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-option/src/lib/types/service.ts new file mode 100644 index 00000000..19d073ea --- /dev/null +++ b/projects/ucap-webmessenger-protocol-option/src/lib/types/service.ts @@ -0,0 +1,18 @@ +export const SVC_TYPE_OPTION = 90; // 옵션 정보 요청 +export const SSVC_TYPE_OPTION_VIEW_REQ = 1; // 옵션 정보 요청 +export const SSVC_TYPE_OPTION_VIEW_RES = 2; // +export const SSVC_TYPE_OPTION_UPD_REQ = 11; // 옵션 변경 요청 +export const SSVC_TYPE_OPTION_UPD_RES = 12; // 옵션 정보 수신 +export const SSVC_TYPE_OPTION_REG_VIEW_REQ = 13; +export const SSVC_TYPE_OPTION_REG_VIEW_RES = 14; +export const SSVC_TYPE_OPTION_REG_UPD_REQ = 15; +export const SSVC_TYPE_OPTION_REG_UPD_RES = 16; +export const SSVC_TYPE_OPTION_CALL_VIEW_REQ = 31; // 통화 옵션 정보 요청 +export const SSVC_TYPE_OPTION_CALL_VIEW_RES = 32; // 통화 옵션 정보 응답 +export const SSVC_TYPE_OPTION_CALL_UPD_REQ = 33; // 통화 옵션 변경 요청 [noused] +export const SSVC_TYPE_OPTION_CALL_UPD_RES = 34; // 통화 옵션 변경 응답 [noused] +export const SSVC_TYPE_OPTION_PUSH_PC_ONLINE_VIEW_REQ = 41; // PC 온라인시 모바일 푸시 옵션 정보 요청 [deprecated] +export const SSVC_TYPE_OPTION_PUSH_PC_ONLINE_VIEW_RES = 42; // PC 온라인시 모바일 푸시 옵션 정보 응답 [deprecated] +export const SSVC_TYPE_OPTION_PUSH_PC_ONLINE_VIEW_UPD_REQ = 51; // PC 온라인시 모바일 푸시 옵션 정보 변경 [deprecated] +export const SSVC_TYPE_OPTION_PUSH_PC_ONLINE_VIEW_UPD_NOTI = 52; // PC 온라인시 모바일 푸시 옵션 정보 변경Noti [deprecated] +export const SSVC_TYPE_OPTION_PUSH_PC_ONLINE_VIEW_UPD_RES = 53; // PC 온라인시 모바일 푸시 옵션 정보 변경응답 [deprecated] diff --git a/projects/ucap-webmessenger-protocol-option/src/public-api.ts b/projects/ucap-webmessenger-protocol-option/src/public-api.ts index 73dfdf23..1f4ba615 100644 --- a/projects/ucap-webmessenger-protocol-option/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-option/src/public-api.ts @@ -2,6 +2,13 @@ * Public API Surface of ucap-webmessenger-protocol-option */ +export * from './lib/models/call-update'; +export * from './lib/models/call-view'; +export * from './lib/models/reg-update'; +export * from './lib/models/reg-view'; +export * from './lib/models/update'; +export * from './lib/models/view'; + export * from './lib/services/option-protocol.service'; export * from './lib/ucap-option-protocol.module';