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

// tslint:disable-next-line: no-empty-interface
export interface LogoutRequest extends ProtocolRequest {}

export interface LogoutResponse extends ProtocolResponse {
  reasonCode?: number;
}

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

  return bodyList;
};

export const decodeLogout: ProtocolDecoder<LogoutResponse> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    reasonCode: message.bodyList[0]
  } as LogoutResponse);
};
