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; };