This commit is contained in:
병준 박 2019-09-25 18:08:57 +09:00
commit 465a3124d3
7 changed files with 296 additions and 1 deletions

View File

@ -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<CancelRequest> = (
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<CancelResponse> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
eventSeq: message.bodyList[1],
deviceType: message.bodyList[2] as DeviceType
} as CancelResponse;
};
export const decodeCancelNotification: ProtocolDecoder<CancelNotification> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
eventSeq: message.bodyList[1],
deviceType: message.bodyList[2] as DeviceType
} as CancelNotification;
};

View File

@ -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<DelRequest> = (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<DelResponse> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
eventSeq: message.bodyList[1]
} as DelResponse;
};
export const decodeDelNotification: ProtocolDecoder<DelNotification> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
eventSeq: message.bodyList[1]
} as DelNotification;
};

View File

@ -0,0 +1,42 @@
import {
ProtocolRequest,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage,
PacketBodyValue
} from '@ucap-webmessenger/protocol';
import { EventType } from '../types/event.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<PushRequest> = (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;
};

View File

@ -0,0 +1,55 @@
import {
ProtocolRequest,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage,
PacketBodyValue,
ProtocolResponse,
ProtocolNotification
} from '@ucap-webmessenger/protocol';
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<ReadRequest> = (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<ReadResponse> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
lastReadSeq: message.bodyList[1]
} as ReadResponse;
};
export const decodeReadNotification: ProtocolDecoder<ReadNotification> = (
message: ProtocolMessage
) => {
return {
roomSeq: message.bodyList[0],
lastReadSeq: message.bodyList[1]
} as ReadNotification;
};

View File

@ -18,7 +18,11 @@ import {
SSVC_TYPE_EVENT_INFO_REQ, SSVC_TYPE_EVENT_INFO_REQ,
SSVC_TYPE_EVENT_INFO_RES, SSVC_TYPE_EVENT_INFO_RES,
SSVC_TYPE_EVENT_INFO_DATA, 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,
SSVC_TYPE_EVENT_DEL_REQ,
SSVC_TYPE_EVENT_CANCEL_REQ
} from '../types/service'; } from '../types/service';
import { import {
SendRequest, SendRequest,
@ -26,6 +30,25 @@ import {
decodeSend, decodeSend,
encodeSend encodeSend
} from '../models/send'; } from '../models/send';
import { PushRequest, encodePush } from '../models/push';
import {
ReadResponse,
ReadRequest,
encodeRead,
decodeRead
} from '../models/read';
import {
DelRequest,
DelResponse,
encodeDel,
decodeDel
} from '@ucap-webmessenger/protocol-buddy';
import {
CancelRequest,
CancelResponse,
encodeCancel,
decodeCancel
} from '../models/cancel';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -63,4 +86,45 @@ 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<ReadResponse> {
return this.protocolService
.call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_READ_REQ, ...encodeRead(req))
.pipe(
take(1),
map(res => {
return decodeRead(res);
})
);
}
public del(req: DelRequest): Observable<DelResponse> {
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<CancelResponse> {
return this.protocolService
.call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_CANCEL_REQ, ...encodeCancel(req))
.pipe(
take(1),
map(res => {
return decodeCancel(res);
})
);
}
} }

View File

@ -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)
}

View File

@ -2,6 +2,9 @@
* Public API Surface of ucap-webmessenger-protocol-event * 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/services/event-protocol.service';
export * from './lib/ucap-event-protocol.module'; export * from './lib/ucap-event-protocol.module';