import {
  ProtocolRequest,
  ProtocolResponse,
  ProtocolEncoder,
  PacketBody,
  PacketBodyValue
} from '@ucap-webmessenger/protocol';
import { StatusInfo } from '../models/status-info';

export interface UnSubscribeRequest extends ProtocolRequest {
  // 사용자SEQ(n)...
  userSeqs: number[];
}

export interface UnSubscribeResponse extends ProtocolResponse {
  // {상태정보}...
  statusInfos: StatusInfo[];
}

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

  req.userSeqs.forEach(userSeq => {
    bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
  });
  return bodyList;
};
