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

View File

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