import { LocaleCode } from '@ucap-webmessenger/core';
import {
  ProtocolRequest,
  ProtocolResponse,
  ProtocolEncoder,
  PacketBody,
  PacketBodyValue,
  ProtocolDecoder,
  ProtocolMessage,
  decodeProtocolMessage
} from '@ucap-webmessenger/protocol';

export interface DownCheckRequest extends ProtocolRequest {
  // 파일SEQ
  seq: number;
}

export interface DownCheckResponse extends ProtocolResponse {
  // 파일SEQ
  seq: number;
}

export const encodeDownCheck: ProtocolEncoder<DownCheckRequest> = (
  req: DownCheckRequest
) => {
  const bodyList: PacketBody[] = [];

  bodyList.push({ type: PacketBodyValue.Integer, value: req.seq });
  return bodyList;
};

export const decodeDownCheck: ProtocolDecoder<DownCheckResponse> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    seq: message.bodyList[0]
  } as DownCheckResponse);
};
