51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { DeviceType, LocaleCode, CallerType } from '@ucap-webmessenger/core';
|
|
import {
|
|
ProtocolRequest,
|
|
ProtocolResponse,
|
|
ProtocolEncoder,
|
|
PacketBody,
|
|
PacketBodyValue,
|
|
ProtocolDecoder,
|
|
ProtocolMessage,
|
|
ProtocolNotification
|
|
} from '@ucap-webmessenger/protocol';
|
|
import { UserInfoUpdateType } from '../types/user-info-update.type';
|
|
|
|
export interface UserOptionResponse extends ProtocolResponse {
|
|
// 타입(s)
|
|
type: CallerType;
|
|
}
|
|
|
|
export const decodeUserOption: ProtocolDecoder<UserOptionResponse> = (
|
|
message: ProtocolMessage
|
|
) => {
|
|
return { type: message.bodyList[0] as CallerType } as UserOptionResponse;
|
|
};
|
|
|
|
export interface UserOptionUpdateRequest extends ProtocolRequest {
|
|
// 타입(s)
|
|
type: CallerType;
|
|
}
|
|
|
|
export interface UserOptionUpdateResponse extends ProtocolResponse {
|
|
// 타입(s)
|
|
type: CallerType;
|
|
}
|
|
|
|
export const encodeUserOptionUpdate: ProtocolEncoder<
|
|
UserOptionUpdateRequest
|
|
> = (req: UserOptionUpdateRequest) => {
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.type });
|
|
return bodyList;
|
|
};
|
|
|
|
export const decodeUserOptionUpdate: ProtocolDecoder<
|
|
UserOptionUpdateResponse
|
|
> = (message: ProtocolMessage) => {
|
|
return {
|
|
type: message.bodyList[0] as CallerType
|
|
} as UserOptionUpdateResponse;
|
|
};
|