This commit is contained in:
leejh 2019-09-25 16:40:35 +09:00
parent 7a1782a39b
commit e4a03d431a
2 changed files with 18 additions and 20 deletions

View File

@ -11,7 +11,7 @@ import {
import { EventType } from '../types/event.type'; import { EventType } from '../types/event.type';
import { PushStatus } from '../types/pushStatus.type'; import { PushStatus } from '../types/pushStatus.type';
export interface EventSendRequest extends ProtocolRequest { export interface SendRequest extends ProtocolRequest {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1. 이벤트타입(s) // 1. 이벤트타입(s)
@ -20,7 +20,7 @@ export interface EventSendRequest extends ProtocolRequest {
sentMessage: string; sentMessage: string;
} }
export interface EventSendResponse extends ProtocolResponse { export interface SendResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 이벤트SEQ(n) // 이벤트SEQ(n)
@ -41,7 +41,7 @@ export interface EventSendResponse extends ProtocolResponse {
senderName: string; senderName: string;
} }
export interface EventSendNotification extends EventSendResponse { export interface SendNotification extends SendResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
// 이벤트SEQ(n) // 이벤트SEQ(n)
// 이벤트타입(s) // 이벤트타입(s)
@ -58,9 +58,7 @@ export interface EventSendNotification extends EventSendResponse {
companyCode?: string; companyCode?: string;
} }
export const encodeEventSend: ProtocolEncoder<EventSendRequest> = ( export const encodeSend: ProtocolEncoder<SendRequest> = (req: SendRequest) => {
req: EventSendRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push( bodyList.push(
@ -72,7 +70,7 @@ export const encodeEventSend: ProtocolEncoder<EventSendRequest> = (
return bodyList; return bodyList;
}; };
export const decodeEventSend: ProtocolDecoder<EventSendResponse> = ( export const decodeSend: ProtocolDecoder<SendResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
@ -85,12 +83,12 @@ export const decodeEventSend: ProtocolDecoder<EventSendResponse> = (
pushStatus: message.bodyList[6] as PushStatus, pushStatus: message.bodyList[6] as PushStatus,
ForcedExitType: message.bodyList[7], ForcedExitType: message.bodyList[7],
senderName: message.bodyList[8] senderName: message.bodyList[8]
} as EventSendResponse; } as SendResponse;
}; };
export const decodeEventSendNotification: ProtocolDecoder< export const decodeSendNotification: ProtocolDecoder<SendNotification> = (
EventSendNotification message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
seq: message.bodyList[1], seq: message.bodyList[1],
@ -103,5 +101,5 @@ export const decodeEventSendNotification: ProtocolDecoder<
senderName: message.bodyList[8], senderName: message.bodyList[8],
id: message.bodyList[9], id: message.bodyList[9],
companyCode: message.bodyList[10] companyCode: message.bodyList[10]
} as EventSendNotification; } as SendNotification;
}; };

View File

@ -21,11 +21,11 @@ import {
SSVC_TYPE_EVENT_SEND_REQ SSVC_TYPE_EVENT_SEND_REQ
} from '../types/service'; } from '../types/service';
import { import {
EventSendRequest, SendRequest,
EventSendResponse, SendResponse,
decodeEventSend, decodeSend,
encodeEventSend encodeSend
} from '../models/event-send'; } from '../models/send';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -53,13 +53,13 @@ export class EventProtocolService {
); );
} }
public eventSend(req: EventSendRequest): Observable<EventSendResponse> { public send(req: SendRequest): Observable<SendResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_SEND_REQ, ...encodeEventSend(req)) .call(SVC_TYPE_EVENT, SSVC_TYPE_EVENT_SEND_REQ, ...encodeSend(req))
.pipe( .pipe(
take(1), take(1),
map(res => { map(res => {
return decodeEventSend(res); return decodeSend(res);
}) })
); );
} }