added protocol EVENT > del,. cancel
This commit is contained in:
parent
c97f49c377
commit
e084f77ce1
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
};
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<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);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue
Block a user