From b3562ab2b3a109488bb6b6a6f992450845b43e3c Mon Sep 17 00:00:00 2001 From: leejh Date: Wed, 25 Sep 2019 17:41:23 +0900 Subject: [PATCH 1/2] added protocol > EVENT > push, read --- .../src/lib/models/push.ts | 43 ++++++++++++++ .../src/lib/models/read.ts | 58 +++++++++++++++++++ .../lib/services/event-protocol.service.ts | 30 +++++++++- .../src/lib/types/pushCl.type.ts | 9 +++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts create mode 100644 projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts create mode 100644 projects/ucap-webmessenger-protocol-event/src/lib/types/pushCl.type.ts diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts new file mode 100644 index 00000000..2dce461a --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts @@ -0,0 +1,43 @@ +import { + ProtocolRequest, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; +import { EventType } from '../types/event.type'; +import { PushStatus } from '../types/pushStatus.type'; +import { PushClType } from '../types/pushCl.type'; + +export interface PushRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 수신자SEQ(n) + receiverSeq: number; + // 푸시타입(s) + type: PushClType; + // 발생일시(s) + sendDate: string; + // 메시지(s) + message: string; + // 제목(s) + title: string; + // 이벤트타입(s) + eventType: EventType; +} + +export const encodePush: ProtocolEncoder = (req: PushRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.Integer, value: req.receiverSeq }, + { type: PacketBodyValue.String, value: req.type }, + { type: PacketBodyValue.String, value: req.sendDate }, + { type: PacketBodyValue.String, value: req.message }, + { type: PacketBodyValue.String, value: req.title }, + { type: PacketBodyValue.String, value: req.eventType } + ); + return bodyList; +}; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts new file mode 100644 index 00000000..d9973ee1 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts @@ -0,0 +1,58 @@ +import { + ProtocolRequest, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + ProtocolResponse, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; +import { EventType } from '../types/event.type'; +import { PushStatus } from '../types/pushStatus.type'; +import { PushClType } from '../types/pushCl.type'; + +export interface ReadRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // LR이벤트SEQ(n) + lastReadSeq: number; +} +export interface ReadResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // LR이벤트SEQ(n) + lastReadSeq: number; +} +export interface ReadNotification extends ProtocolNotification { + // 대화방SEQ(s) + roomSeq: string; + // LR이벤트SEQ(n) + lastReadSeq: number; +} + +export const encodeRead: ProtocolEncoder = (req: ReadRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.Integer, value: req.lastReadSeq } + ); + return bodyList; +}; +export const decodeRead: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + lastReadSeq: message.bodyList[1] + } as ReadResponse; +}; +export const decodeReadNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + lastReadSeq: message.bodyList[1] + } as ReadNotification; +}; 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 2ebab844..e00ed4f3 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 @@ -18,7 +18,9 @@ import { SSVC_TYPE_EVENT_INFO_REQ, SSVC_TYPE_EVENT_INFO_RES, SSVC_TYPE_EVENT_INFO_DATA, - SSVC_TYPE_EVENT_SEND_REQ + SSVC_TYPE_EVENT_SEND_REQ, + SSVC_TYPE_EVENT_PUSH_CL_REQ, + SSVC_TYPE_EVENT_READ_REQ } from '../types/service'; import { SendRequest, @@ -26,6 +28,13 @@ import { decodeSend, encodeSend } from '../models/send'; +import { PushRequest, encodePush } from '../models/push'; +import { + ReadResponse, + ReadRequest, + encodeRead, + decodeRead +} from '../models/read'; @Injectable({ providedIn: 'root' @@ -63,4 +72,23 @@ export class EventProtocolService { }) ); } + + public push(req: PushRequest): void { + return this.protocolService.send( + SVC_TYPE_EVENT, + SSVC_TYPE_EVENT_PUSH_CL_REQ, + ...encodePush(req) + ); + } + + public read(req: ReadRequest): Observable { + return this.protocolService + .call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_READ_REQ, ...encodeRead(req)) + .pipe( + take(1), + map(res => { + return decodeRead(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/types/pushCl.type.ts b/projects/ucap-webmessenger-protocol-event/src/lib/types/pushCl.type.ts new file mode 100644 index 00000000..836bf5e4 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/types/pushCl.type.ts @@ -0,0 +1,9 @@ +export enum PushClType { + Message = 'M', // Message + LoginAlarm = 'L', // LOG IN Alaram + FMC = 'F', // FMC Wake + Call = 'C', // FMC Call + BriefNote = 'B', // 쪽지(Brief note) + Announce = 'A', // 알림(Announce) + Gongji = 'G' // 공지(Gongji) +} From e084f77ce1239e5c922d0fc49367aa4482c88e81 Mon Sep 17 00:00:00 2001 From: leejh Date: Wed, 25 Sep 2019 18:02:15 +0900 Subject: [PATCH 2/2] added protocol EVENT > del,. cancel --- .../src/lib/models/cancel.ts | 67 +++++++++++++++++++ .../src/lib/models/del.ts | 55 +++++++++++++++ .../src/lib/models/push.ts | 1 - .../src/lib/models/read.ts | 3 - .../lib/services/event-protocol.service.ts | 38 ++++++++++- .../src/public-api.ts | 3 + 6 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 projects/ucap-webmessenger-protocol-event/src/lib/models/cancel.ts create mode 100644 projects/ucap-webmessenger-protocol-event/src/lib/models/del.ts diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/cancel.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/cancel.ts new file mode 100644 index 00000000..2b56c0f5 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/cancel.ts @@ -0,0 +1,67 @@ +import { + ProtocolRequest, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + ProtocolResponse, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; +import { DeviceType } from '@ucap-webmessenger/core'; + +export interface CancelRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; + // 단말타입(s) + deviceType: DeviceType; +} +export interface CancelResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; + // 단말타입(s) + deviceType: DeviceType; +} +export interface CancelNotification extends ProtocolNotification { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; + // 단말타입(s) + deviceType: DeviceType; +} + +export const encodeCancel: ProtocolEncoder = ( + req: CancelRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.Integer, value: req.eventSeq }, + { type: PacketBodyValue.String, value: req.deviceType } + ); + return bodyList; +}; +export const decodeCancel: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + eventSeq: message.bodyList[1], + deviceType: message.bodyList[2] as DeviceType + } as CancelResponse; +}; +export const decodeCancelNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + eventSeq: message.bodyList[1], + deviceType: message.bodyList[2] as DeviceType + } as CancelNotification; +}; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/del.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/del.ts new file mode 100644 index 00000000..893b510c --- /dev/null +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/del.ts @@ -0,0 +1,55 @@ +import { + ProtocolRequest, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue, + ProtocolResponse, + ProtocolNotification +} from '@ucap-webmessenger/protocol'; + +export interface DelRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; +} +export interface DelResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; +} +export interface DelNotification extends ProtocolNotification { + // 대화방SEQ(s) + roomSeq: string; + // 이벤트SEQ(n) + eventSeq: number; +} + +export const encodeDel: ProtocolEncoder = (req: DelRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push( + { type: PacketBodyValue.String, value: req.roomSeq }, + { type: PacketBodyValue.Integer, value: req.eventSeq } + ); + return bodyList; +}; +export const decodeDel: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + eventSeq: message.bodyList[1] + } as DelResponse; +}; +export const decodeDelNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + eventSeq: message.bodyList[1] + } as DelNotification; +}; diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts index 2dce461a..ba01d642 100644 --- a/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/push.ts @@ -7,7 +7,6 @@ import { PacketBodyValue } from '@ucap-webmessenger/protocol'; import { EventType } from '../types/event.type'; -import { PushStatus } from '../types/pushStatus.type'; import { PushClType } from '../types/pushCl.type'; export interface PushRequest extends ProtocolRequest { diff --git a/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts b/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts index d9973ee1..6883696c 100644 --- a/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts +++ b/projects/ucap-webmessenger-protocol-event/src/lib/models/read.ts @@ -8,9 +8,6 @@ import { ProtocolResponse, ProtocolNotification } from '@ucap-webmessenger/protocol'; -import { EventType } from '../types/event.type'; -import { PushStatus } from '../types/pushStatus.type'; -import { PushClType } from '../types/pushCl.type'; export interface ReadRequest extends ProtocolRequest { // 대화방SEQ(s) 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 e00ed4f3..a16c5f19 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 @@ -20,7 +20,9 @@ import { SSVC_TYPE_EVENT_INFO_DATA, SSVC_TYPE_EVENT_SEND_REQ, SSVC_TYPE_EVENT_PUSH_CL_REQ, - SSVC_TYPE_EVENT_READ_REQ + SSVC_TYPE_EVENT_READ_REQ, + SSVC_TYPE_EVENT_DEL_REQ, + SSVC_TYPE_EVENT_CANCEL_REQ } from '../types/service'; import { SendRequest, @@ -35,6 +37,18 @@ import { encodeRead, decodeRead } from '../models/read'; +import { + DelRequest, + DelResponse, + encodeDel, + decodeDel +} from '@ucap-webmessenger/protocol-buddy'; +import { + CancelRequest, + CancelResponse, + encodeCancel, + decodeCancel +} from '../models/cancel'; @Injectable({ providedIn: 'root' @@ -91,4 +105,26 @@ export class EventProtocolService { }) ); } + + public del(req: DelRequest): Observable { + return this.protocolService + .call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_DEL_REQ, ...encodeDel(req)) + .pipe( + take(1), + map(res => { + return decodeDel(res); + }) + ); + } + + public cancel(req: CancelRequest): Observable { + return this.protocolService + .call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_CANCEL_REQ, ...encodeCancel(req)) + .pipe( + take(1), + map(res => { + return decodeCancel(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-event/src/public-api.ts b/projects/ucap-webmessenger-protocol-event/src/public-api.ts index 6be7cdd3..edb73779 100644 --- a/projects/ucap-webmessenger-protocol-event/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-event/src/public-api.ts @@ -2,6 +2,9 @@ * Public API Surface of ucap-webmessenger-protocol-event */ +export * from './lib/models/info'; +export * from './lib/models/send'; + export * from './lib/services/event-protocol.service'; export * from './lib/ucap-event-protocol.module';