2019-09-25 13:21:07 +09:00
|
|
|
import {
|
|
|
|
ProtocolRequest,
|
|
|
|
ProtocolResponse,
|
|
|
|
ProtocolEncoder,
|
|
|
|
PacketBody,
|
|
|
|
PacketBodyValue,
|
|
|
|
ProtocolDecoder,
|
|
|
|
ProtocolMessage
|
|
|
|
} from '@ucap-webmessenger/protocol';
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateRequest extends ProtocolRequest {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 대화방제목(s)
|
|
|
|
roomName: string;
|
|
|
|
// 알람여부(y)
|
|
|
|
isAlarm: boolean;
|
|
|
|
// 동기화여부(s)
|
|
|
|
isSyncAll: boolean;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateResponse extends ProtocolResponse {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 대화방제목(s)
|
|
|
|
roomName: string;
|
|
|
|
// 알람여부(y)
|
|
|
|
isAlarm: boolean;
|
|
|
|
// 동기화여부(s)
|
|
|
|
isSyncAll: boolean;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
|
|
|
|
req: UpdateRequest
|
2019-09-25 13:21:07 +09:00
|
|
|
) => {
|
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomName });
|
|
|
|
bodyList.push({
|
|
|
|
type: PacketBodyValue.String,
|
|
|
|
value: req.isAlarm ? 'Y' : 'N'
|
|
|
|
});
|
|
|
|
bodyList.push({
|
|
|
|
type: PacketBodyValue.String,
|
|
|
|
value: req.isSyncAll ? 'Y' : 'N'
|
|
|
|
});
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
|
2019-09-25 13:21:07 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
roomName: message.bodyList[1],
|
|
|
|
isAlarm: message.bodyList[2] === 'Y' ? true : false,
|
|
|
|
isSyncAll: message.bodyList[3] === 'Y' ? true : false
|
2019-09-25 16:13:33 +09:00
|
|
|
} as UpdateResponse;
|
2019-09-25 13:21:07 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateTimerSetRequest extends ProtocolRequest {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 타이머시간(n)
|
|
|
|
timerInterval: number;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateTimerSetResponse extends ProtocolResponse {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 타이머시간(n)
|
|
|
|
timerInterval: number;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const encodeUpdateTimerSet: ProtocolEncoder<UpdateTimerSetRequest> = (
|
|
|
|
req: UpdateTimerSetRequest
|
|
|
|
) => {
|
2019-09-25 13:21:07 +09:00
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
|
|
|
|
bodyList.push({ type: PacketBodyValue.Integer, value: req.timerInterval });
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUpdateTimerSet: ProtocolDecoder<UpdateTimerSetResponse> = (
|
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
2019-09-25 13:21:07 +09:00
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
timerInterval: message.bodyList[1] || 0
|
2019-09-25 16:13:33 +09:00
|
|
|
} as UpdateTimerSetResponse;
|
2019-09-25 13:21:07 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateFontRequest extends ProtocolRequest {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 폰트색(s) cf)0x000000 형태의 스트링
|
|
|
|
fontColor: string;
|
|
|
|
// sender사용자SEQ(n)
|
|
|
|
senderSeq: number;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export interface UpdateFontResponse extends ProtocolResponse {
|
2019-09-25 13:21:07 +09:00
|
|
|
// 대화방SEQ(s)
|
|
|
|
roomSeq: string;
|
|
|
|
// 폰트색(s) cf)0x000000 형태의 스트링
|
|
|
|
fontColor: string;
|
|
|
|
// sender사용자SEQ(n)
|
|
|
|
senderSeq: number;
|
|
|
|
}
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const encodeUpdateFont: ProtocolEncoder<UpdateFontRequest> = (
|
|
|
|
req: UpdateFontRequest
|
2019-09-25 13:21:07 +09:00
|
|
|
) => {
|
|
|
|
const bodyList: PacketBody[] = [];
|
|
|
|
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
|
|
|
|
bodyList.push({ type: PacketBodyValue.String, value: req.fontColor });
|
|
|
|
bodyList.push({ type: PacketBodyValue.Integer, value: req.senderSeq });
|
|
|
|
return bodyList;
|
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUpdateFont: ProtocolDecoder<UpdateFontResponse> = (
|
2019-09-25 13:21:07 +09:00
|
|
|
message: ProtocolMessage
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
fontColor: message.bodyList[1],
|
|
|
|
senderSeq: message.bodyList[2]
|
2019-09-25 16:13:33 +09:00
|
|
|
} as UpdateFontResponse;
|
2019-09-25 13:21:07 +09:00
|
|
|
};
|
|
|
|
|
2019-09-25 16:13:33 +09:00
|
|
|
export const decodeUpdateFontNotification: ProtocolDecoder<
|
|
|
|
UpdateFontResponse
|
2019-09-25 13:21:07 +09:00
|
|
|
> = (message: ProtocolMessage) => {
|
|
|
|
return {
|
|
|
|
roomSeq: message.bodyList[0],
|
|
|
|
fontColor: message.bodyList[1],
|
|
|
|
senderSeq: message.bodyList[2]
|
2019-09-25 16:13:33 +09:00
|
|
|
} as UpdateFontResponse;
|
2019-09-25 13:21:07 +09:00
|
|
|
};
|