This commit is contained in:
leejh 2019-09-25 16:13:33 +09:00
parent d4abaeea32
commit d2ac61381a
15 changed files with 280 additions and 329 deletions

View File

@ -9,19 +9,17 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface BuddyAddRequest extends ProtocolRequest { export interface AddRequest extends ProtocolRequest {
// 0n. 사용자SEQ(n)... // 0n. 사용자SEQ(n)...
userSeqs: number[]; userSeqs: number[];
} }
export interface BuddyAddResponse extends ProtocolResponse { export interface AddResponse extends ProtocolResponse {
// 0n. 사용자SEQ(n)... // 0n. 사용자SEQ(n)...
userSeqs: number[]; userSeqs: number[];
} }
export const encodeBuddyAdd: ProtocolEncoder<BuddyAddRequest> = ( export const encodeAdd: ProtocolEncoder<AddRequest> = (req: AddRequest) => {
req: BuddyAddRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
for (const userSeq of req.userSeqs) { for (const userSeq of req.userSeqs) {
@ -31,11 +29,11 @@ export const encodeBuddyAdd: ProtocolEncoder<BuddyAddRequest> = (
return bodyList; return bodyList;
}; };
export const decodeBuddyAdd: ProtocolDecoder<BuddyAddResponse> = ( export const decodeAdd: ProtocolDecoder<AddResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const userSeqArray: number[] = [...message.bodyList]; const userSeqArray: number[] = [...message.bodyList];
return { return {
userSeqs: userSeqArray userSeqs: userSeqArray
} as BuddyAddResponse; } as AddResponse;
}; };

View File

@ -9,19 +9,17 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface BuddyDelRequest extends ProtocolRequest { export interface DelRequest extends ProtocolRequest {
// 0n. 사용자SEQ(n)... // 0n. 사용자SEQ(n)...
userSeqs: number[]; userSeqs: number[];
} }
export interface BuddyDelResponse extends ProtocolResponse { export interface DelResponse extends ProtocolResponse {
// 0n. 사용자SEQ(n)... // 0n. 사용자SEQ(n)...
userSeqs: number[]; userSeqs: number[];
} }
export const encodeBuddyDel: ProtocolEncoder<BuddyDelRequest> = ( export const encodeDel: ProtocolEncoder<DelRequest> = (req: DelRequest) => {
req: BuddyDelRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
for (const userSeq of req.userSeqs) { for (const userSeq of req.userSeqs) {
@ -31,11 +29,11 @@ export const encodeBuddyDel: ProtocolEncoder<BuddyDelRequest> = (
return bodyList; return bodyList;
}; };
export const decodeBuddyDel: ProtocolDecoder<BuddyDelResponse> = ( export const decodeDel: ProtocolDecoder<DelResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const userSeqArray: number[] = [...message.bodyList]; const userSeqArray: number[] = [...message.bodyList];
return { return {
userSeqs: userSeqArray userSeqs: userSeqArray
} as BuddyDelResponse; } as DelResponse;
}; };

View File

@ -9,22 +9,22 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface BuddyUpdateRequest extends ProtocolRequest { export interface UpdateRequest extends ProtocolRequest {
// 0. 사용자SEQ(n) // 0. 사용자SEQ(n)
seq: number; seq: number;
// 1. 즐겨찾기여부(y) // 1. 즐겨찾기여부(y)
isFavorit: boolean; isFavorit: boolean;
} }
export interface BuddyUpdateResponse extends ProtocolResponse { export interface UpdateResponse extends ProtocolResponse {
// 0. 사용자SEQ(n) // 0. 사용자SEQ(n)
seq: number; seq: number;
// 1. 즐겨찾기여부(y) // 1. 즐겨찾기여부(y)
isFavorit: boolean; isFavorit: boolean;
} }
export const encodeBuddyUpdate: ProtocolEncoder<BuddyUpdateRequest> = ( export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
req: BuddyUpdateRequest req: UpdateRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -37,11 +37,11 @@ export const encodeBuddyUpdate: ProtocolEncoder<BuddyUpdateRequest> = (
return bodyList; return bodyList;
}; };
export const decodeBuddyUpdate: ProtocolDecoder<BuddyUpdateResponse> = ( export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
seq: message.bodyList[0], seq: message.bodyList[0],
isFavorit: message.bodyList[1] === 'Y' ? true : false isFavorit: message.bodyList[1] === 'Y' ? true : false
} as BuddyUpdateResponse; } as UpdateResponse;
}; };

View File

@ -12,23 +12,13 @@ import {
SSVC_TYPE_BUDDY_UPD_REQ SSVC_TYPE_BUDDY_UPD_REQ
} from '../types/service'; } from '../types/service';
import { AddRequest, encodeAdd, decodeAdd, AddResponse } from '../models/add';
import { DelRequest, encodeDel, decodeDel, DelResponse } from '../models/del';
import { import {
BuddyAddRequest, UpdateRequest,
encodeBuddyAdd, decodeUpdate,
decodeBuddyAdd, encodeUpdate,
BuddyAddResponse UpdateResponse
} from '../models/add';
import {
BuddyDelRequest,
encodeBuddyDel,
decodeBuddyDel,
BuddyDelResponse
} from '../models/del';
import {
BuddyUpdateRequest,
decodeBuddyUpdate,
encodeBuddyUpdate,
BuddyUpdateResponse
} from '../models/update'; } from '../models/update';
@Injectable({ @Injectable({
@ -37,30 +27,30 @@ import {
export class BuddyProtocolService { export class BuddyProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public buddyAdd(req: BuddyAddRequest): Observable<BuddyAddResponse> { public add(req: AddRequest): Observable<AddResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeBuddyAdd(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeAdd(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeBuddyAdd(res)) map(res => decodeAdd(res))
); );
} }
public buddyDel(req: BuddyDelRequest): Observable<BuddyDelResponse> { public del(req: DelRequest): Observable<DelResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeBuddyDel(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeDel(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeBuddyDel(res)) map(res => decodeDel(res))
); );
} }
public buddyUpdate(req: BuddyUpdateRequest): Observable<BuddyUpdateResponse> { public update(req: UpdateRequest): Observable<UpdateResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeBuddyUpdate(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeUpdate(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeBuddyUpdate(res)) map(res => decodeUpdate(res))
); );
} }
} }

View File

@ -9,21 +9,19 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface GroupAddRequest extends ProtocolRequest { export interface AddRequest extends ProtocolRequest {
// 0. 동료그룹이름 // 0. 동료그룹이름
groupName: string; groupName: string;
} }
export interface GroupAddResponse extends ProtocolResponse { export interface AddResponse extends ProtocolResponse {
// 0: 동료그룹SEQ(n) // 0: 동료그룹SEQ(n)
groupSeq: number; groupSeq: number;
// 1: 동료그룹이름(s) // 1: 동료그룹이름(s)
groupName: string; groupName: string;
} }
export const encodeGroupAdd: ProtocolEncoder<GroupAddRequest> = ( export const encodeAdd: ProtocolEncoder<AddRequest> = (req: AddRequest) => {
req: GroupAddRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.groupName }); bodyList.push({ type: PacketBodyValue.String, value: req.groupName });
@ -31,11 +29,11 @@ export const encodeGroupAdd: ProtocolEncoder<GroupAddRequest> = (
return bodyList; return bodyList;
}; };
export const decodeGroupAdd: ProtocolDecoder<GroupAddResponse> = ( export const decodeAdd: ProtocolDecoder<AddResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
groupSeq: message.bodyList[0], groupSeq: message.bodyList[0],
groupName: message.bodyList[1] groupName: message.bodyList[1]
} as GroupAddResponse; } as AddResponse;
}; };

View File

@ -9,19 +9,17 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface GroupDelRequest extends ProtocolRequest { export interface DelRequest extends ProtocolRequest {
// 0: 동료그룹SEQ(n) // 0: 동료그룹SEQ(n)
groupSeq: number; groupSeq: number;
} }
export interface GroupDelResponse extends ProtocolResponse { export interface DelResponse extends ProtocolResponse {
// 0: 동료그룹SEQ(n) // 0: 동료그룹SEQ(n)
groupSeq: number; groupSeq: number;
} }
export const encodeGroupDel: ProtocolEncoder<GroupDelRequest> = ( export const encodeDel: ProtocolEncoder<DelRequest> = (req: DelRequest) => {
req: GroupDelRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.Integer, value: req.groupSeq }); bodyList.push({ type: PacketBodyValue.Integer, value: req.groupSeq });
@ -29,10 +27,10 @@ export const encodeGroupDel: ProtocolEncoder<GroupDelRequest> = (
return bodyList; return bodyList;
}; };
export const decodeGroupDel: ProtocolDecoder<GroupDelResponse> = ( export const decodeDel: ProtocolDecoder<DelResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
groupSeq: message.bodyList[0] groupSeq: message.bodyList[0]
} as GroupDelResponse; } as DelResponse;
}; };

View File

@ -9,7 +9,7 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface GroupUpdateRequest extends ProtocolRequest { export interface UpdateRequest extends ProtocolRequest {
// 0: 동료그룹SEQ(n) // 0: 동료그룹SEQ(n)
groupSeq: number; groupSeq: number;
// 1: 동료그룹이름(s) // 1: 동료그룹이름(s)
@ -18,7 +18,7 @@ export interface GroupUpdateRequest extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export interface GroupUpdateResponse extends ProtocolResponse { export interface UpdateResponse extends ProtocolResponse {
// 0: 동료그룹SEQ(n) // 0: 동료그룹SEQ(n)
groupSeq: number; groupSeq: number;
// 1: 동료그룹이름(s) // 1: 동료그룹이름(s)
@ -27,8 +27,8 @@ export interface GroupUpdateResponse extends ProtocolResponse {
userSeqs: number[]; userSeqs: number[];
} }
export const encodeGroupUpdate: ProtocolEncoder<GroupUpdateRequest> = ( export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
req: GroupUpdateRequest req: UpdateRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -41,7 +41,7 @@ export const encodeGroupUpdate: ProtocolEncoder<GroupUpdateRequest> = (
return bodyList; return bodyList;
}; };
export const decodeGroupUpdate: ProtocolDecoder<GroupUpdateResponse> = ( export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
let userSeqArray: number[] = []; let userSeqArray: number[] = [];
@ -53,11 +53,11 @@ export const decodeGroupUpdate: ProtocolDecoder<GroupUpdateResponse> = (
groupSeq: message.bodyList[0], groupSeq: message.bodyList[0],
groupName: message.bodyList[1], groupName: message.bodyList[1],
userSeqs: userSeqArray userSeqs: userSeqArray
} as GroupUpdateResponse; } as UpdateResponse;
}; };
export const encodeGroupUpdate2: ProtocolEncoder<GroupUpdateRequest> = ( export const encodeUpdate2: ProtocolEncoder<UpdateRequest> = (
req: GroupUpdateRequest req: UpdateRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -75,7 +75,7 @@ export const encodeGroupUpdate2: ProtocolEncoder<GroupUpdateRequest> = (
return bodyList; return bodyList;
}; };
export const decodeGroupUpdate2: ProtocolDecoder<GroupUpdateResponse> = ( export const decodeUpdate2: ProtocolDecoder<UpdateResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
let userSeqArray: number[] = []; let userSeqArray: number[] = [];
@ -87,5 +87,5 @@ export const decodeGroupUpdate2: ProtocolDecoder<GroupUpdateResponse> = (
groupSeq: message.bodyList[0], groupSeq: message.bodyList[0],
groupName: message.bodyList[1], groupName: message.bodyList[1],
userSeqs: userSeqArray userSeqs: userSeqArray
} as GroupUpdateResponse; } as UpdateResponse;
}; };

View File

@ -4,12 +4,6 @@ import { Observable } from 'rxjs';
import { map, take } from 'rxjs/operators'; import { map, take } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import {
GroupAddRequest,
encodeGroupAdd,
decodeGroupAdd,
GroupAddResponse
} from '../models/add';
import { import {
SVC_TYPE_GROUP, SVC_TYPE_GROUP,
SSVC_TYPE_GROUP_ADD_REQ, SSVC_TYPE_GROUP_ADD_REQ,
@ -17,19 +11,15 @@ import {
SSVC_TYPE_GROUP_UPD_REQ, SSVC_TYPE_GROUP_UPD_REQ,
SSVC_TYPE_GROUP_UPD_REQ2 SSVC_TYPE_GROUP_UPD_REQ2
} from '../types/service'; } from '../types/service';
import { AddRequest, encodeAdd, decodeAdd, AddResponse } from '../models/add';
import { DelRequest, encodeDel, decodeDel, DelResponse } from '../models/del';
import { import {
GroupDelRequest, UpdateRequest,
encodeGroupDel, encodeUpdate,
decodeGroupDel, decodeUpdate,
GroupDelResponse encodeUpdate2,
} from '../models/del'; decodeUpdate2,
import { UpdateResponse
GroupUpdateRequest,
encodeGroupUpdate,
decodeGroupUpdate,
encodeGroupUpdate2,
decodeGroupUpdate2,
GroupUpdateResponse
} from '../models/update'; } from '../models/update';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -37,45 +27,39 @@ import {
export class GroupProtocolService { export class GroupProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public groupAdd(req: GroupAddRequest): Observable<GroupAddResponse> { public add(req: AddRequest): Observable<AddResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeAdd(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeGroupAdd(res)) map(res => decodeAdd(res))
); );
} }
public groupDel(req: GroupDelRequest): Observable<GroupDelResponse> { public del(req: DelRequest): Observable<DelResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeDel(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeGroupDel(res)) map(res => decodeDel(res))
); );
} }
public groupUpdate(req: GroupUpdateRequest): Observable<GroupUpdateResponse> { public update(req: UpdateRequest): Observable<UpdateResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeUpdate(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeGroupUpdate(res)) map(res => decodeUpdate(res))
); );
} }
public groupUpdate2( public update2(req: UpdateRequest): Observable<UpdateResponse> {
req: GroupUpdateRequest
): Observable<GroupUpdateResponse> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ2, ...encodeUpdate2(req))
SVC_TYPE_GROUP,
SSVC_TYPE_GROUP_UPD_REQ2,
...encodeGroupUpdate2(req)
)
.pipe( .pipe(
take(1), take(1),
map(res => decodeGroupUpdate2(res)) map(res => decodeUpdate2(res))
); );
} }
} }

View File

@ -9,47 +9,45 @@ import {
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
import { RoomExitType } from '../types/room.type'; import { RoomExitType } from '../types/room.type';
export interface RoomExitRequest extends ProtocolRequest { export interface ExitRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
} }
export interface RoomExitResponse extends ProtocolResponse { export interface ExitResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
} }
export const encodeRoomExit: ProtocolEncoder<RoomExitRequest> = ( export const encodeExit: ProtocolEncoder<ExitRequest> = (req: ExitRequest) => {
req: RoomExitRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
return bodyList; return bodyList;
}; };
export const decodeRoomExit: ProtocolDecoder<RoomExitResponse> = ( export const decodeExit: ProtocolDecoder<ExitResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
roomSeq: message.bodyList[0] roomSeq: message.bodyList[0]
} as RoomExitResponse; } as ExitResponse;
}; };
export const decodeRoomExitNotification: ProtocolDecoder<RoomExitResponse> = ( export const decodeExitNotification: ProtocolDecoder<ExitResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
roomSeq: message.bodyList[0] roomSeq: message.bodyList[0]
} as RoomExitResponse; } as ExitResponse;
}; };
export interface RoomExitAllRequest extends ProtocolRequest { export interface ExitAllRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string[]; roomSeq: string[];
} }
export const encodeRoomAllExit: ProtocolEncoder<RoomExitAllRequest> = ( export const encodeAllExit: ProtocolEncoder<ExitAllRequest> = (
req: RoomExitAllRequest req: ExitAllRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -57,7 +55,7 @@ export const encodeRoomAllExit: ProtocolEncoder<RoomExitAllRequest> = (
return bodyList; return bodyList;
}; };
export interface RoomExitForcingRequest extends ProtocolRequest { export interface ExitForcingRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 강퇴요청타입(s) // 강퇴요청타입(s)
@ -68,7 +66,7 @@ export interface RoomExitForcingRequest extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export interface RoomExitForcingResponse extends ProtocolRequest { export interface ExitForcingResponse extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 강퇴요청타입(s) // 강퇴요청타입(s)
@ -79,8 +77,8 @@ export interface RoomExitForcingResponse extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export const encodeRoomExitForcing: ProtocolEncoder<RoomExitForcingRequest> = ( export const encodeExitForcing: ProtocolEncoder<ExitForcingRequest> = (
req: RoomExitForcingRequest req: ExitForcingRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -93,7 +91,7 @@ export const encodeRoomExitForcing: ProtocolEncoder<RoomExitForcingRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomExitForcing: ProtocolDecoder<RoomExitForcingResponse> = ( export const decodeExitForcing: ProtocolDecoder<ExitForcingResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
let userSeqs: number[] = []; let userSeqs: number[] = [];
@ -105,10 +103,10 @@ export const decodeRoomExitForcing: ProtocolDecoder<RoomExitForcingResponse> = (
type: message.bodyList[1] as RoomExitType, type: message.bodyList[1] as RoomExitType,
senderSeq: message.bodyList[2], senderSeq: message.bodyList[2],
userSeqs userSeqs
} as RoomExitForcingResponse; } as ExitForcingResponse;
}; };
export const decodeRoomExitForcingNotification: ProtocolDecoder< export const decodeExitForcingNotification: ProtocolDecoder<
RoomExitForcingResponse ExitForcingResponse
> = (message: ProtocolMessage) => { > = (message: ProtocolMessage) => {
let userSeqs: number[] = []; let userSeqs: number[] = [];
if (message.bodyList.length > 3) { if (message.bodyList.length > 3) {
@ -119,5 +117,5 @@ export const decodeRoomExitForcingNotification: ProtocolDecoder<
type: message.bodyList[1] as RoomExitType, type: message.bodyList[1] as RoomExitType,
senderSeq: message.bodyList[2], senderSeq: message.bodyList[2],
userSeqs userSeqs
} as RoomExitForcingResponse; } as ExitForcingResponse;
}; };

View File

@ -6,7 +6,8 @@ import {
PacketBodyValue, PacketBodyValue,
ProtocolDecoder, ProtocolDecoder,
ProtocolMessage, ProtocolMessage,
BodyStringDivider BodyStringDivider,
ProtocolStream
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
import { LocaleCode } from '@ucap-webmessenger/core'; import { LocaleCode } from '@ucap-webmessenger/core';
import { RoomType } from '../types/room.type'; import { RoomType } from '../types/room.type';
@ -137,7 +138,7 @@ export interface UserInfo {
id: string; id: string;
} }
export interface RoomInfoRequest extends ProtocolRequest { export interface InfoRequest extends ProtocolRequest {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1. 상세정보여부(y) // 1. 상세정보여부(y)
@ -146,34 +147,32 @@ export interface RoomInfoRequest extends ProtocolRequest {
localeCode: LocaleCode; localeCode: LocaleCode;
} }
export interface RoomInfoResponse extends ProtocolResponse { export interface InfoResponse extends ProtocolResponse {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
} }
export interface RoomInfoDataResponse extends ProtocolResponse { export interface InfoData extends ProtocolStream {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1. {대화방정보} // 1. {대화방정보}
roomInfo: RoomInfo; roomInfo: RoomInfo;
} }
export interface RoomUserShortDataResponse extends ProtocolResponse { export interface UserShortData extends ProtocolStream {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보} // 1n. {참여자정보}
userInfos: UserInfoShort[]; userInfos: UserInfoShort[];
} }
export interface RoomUserDataResponse extends ProtocolResponse { export interface UserData extends ProtocolStream {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보-D} // 1n. {참여자정보-D}
userInfos: UserInfo[]; userInfos: UserInfo[];
} }
export const encodeRoomInfo: ProtocolEncoder<RoomInfoRequest> = ( export const encodeInfo: ProtocolEncoder<InfoRequest> = (req: InfoRequest) => {
req: RoomInfoRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
@ -186,15 +185,15 @@ export const encodeRoomInfo: ProtocolEncoder<RoomInfoRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomInfo: ProtocolDecoder<RoomInfoResponse> = ( export const decodeInfo: ProtocolDecoder<InfoResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
roomSeq: message.bodyList[0] roomSeq: message.bodyList[0]
} as RoomInfoResponse; } as InfoResponse;
}; };
export const decodeRoomInfoData: ProtocolDecoder<RoomInfoDataResponse> = ( export const decodeInfoData: ProtocolDecoder<InfoData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
let roomInfo: RoomInfo = null; let roomInfo: RoomInfo = null;
@ -222,12 +221,12 @@ export const decodeRoomInfoData: ProtocolDecoder<RoomInfoDataResponse> = (
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
roomInfo roomInfo
} as RoomInfoDataResponse; } as InfoData;
}; };
export const decodeRoomUserShortData: ProtocolDecoder< export const decodeUserShortData: ProtocolDecoder<UserShortData> = (
RoomUserShortDataResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
const userInfos: UserInfoShort[] = []; const userInfos: UserInfoShort[] = [];
message.bodyList.slice(1).forEach(userInfo => { message.bodyList.slice(1).forEach(userInfo => {
const info = userInfo.split(BodyStringDivider); const info = userInfo.split(BodyStringDivider);
@ -252,10 +251,10 @@ export const decodeRoomUserShortData: ProtocolDecoder<
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as RoomUserShortDataResponse; } as UserShortData;
}; };
export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = ( export const decodeUserData: ProtocolDecoder<UserData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const userInfos: UserInfo[] = []; const userInfos: UserInfo[] = [];
@ -298,30 +297,30 @@ export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = (
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as RoomUserDataResponse; } as UserData;
}; };
export interface RoomUserStatusOfflineRequest extends ProtocolRequest { export interface UserStatusOfflineRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
} }
export interface RoomUserStatusOfflineResponse extends ProtocolResponse { export interface UserStatusOfflineResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 사용자SEQ(n)... // 사용자SEQ(n)...
userSeqs: number[]; userSeqs: number[];
} }
export const encodeRoomUserStatusOffline: ProtocolEncoder< export const encodeUserStatusOffline: ProtocolEncoder<
RoomUserStatusOfflineRequest UserStatusOfflineRequest
> = (req: RoomUserStatusOfflineRequest) => { > = (req: UserStatusOfflineRequest) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
return bodyList; return bodyList;
}; };
export const decodeRoomUserStatusOffline: ProtocolDecoder< export const decodeUserStatusOffline: ProtocolDecoder<
RoomUserStatusOfflineResponse UserStatusOfflineResponse
> = (message: ProtocolMessage) => { > = (message: ProtocolMessage) => {
let userSeqs: number[] = []; let userSeqs: number[] = [];
if (message.bodyList.length > 1) { if (message.bodyList.length > 1) {
@ -330,5 +329,5 @@ export const decodeRoomUserStatusOffline: ProtocolDecoder<
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userSeqs userSeqs
} as RoomUserStatusOfflineResponse; } as UserStatusOfflineResponse;
}; };

View File

@ -8,20 +8,20 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface RoomInviteRequest extends ProtocolRequest { export interface InviteRequest extends ProtocolRequest {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. 초대자 userSeq(n)... // 1n. 초대자 userSeq(n)...
inviteUserSeqs: number[]; inviteUserSeqs: number[];
} }
export interface RoomInviteResponse extends ProtocolResponse { export interface InviteResponse extends ProtocolResponse {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
} }
export const encodeRoomInvite: ProtocolEncoder<RoomInviteRequest> = ( export const encodeInvite: ProtocolEncoder<InviteRequest> = (
req: RoomInviteRequest req: InviteRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -33,18 +33,18 @@ export const encodeRoomInvite: ProtocolEncoder<RoomInviteRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomInvite: ProtocolDecoder<RoomInviteResponse> = ( export const decodeInvite: ProtocolDecoder<InviteResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
roomSeq: message.bodyList[0] roomSeq: message.bodyList[0]
} as RoomInviteResponse; } as InviteResponse;
}; };
export const decodeRoomInviteNotification: ProtocolDecoder< export const decodeInviteNotification: ProtocolDecoder<InviteResponse> = (
RoomInviteResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
return { return {
roomSeq: message.bodyList[0] roomSeq: message.bodyList[0]
} as RoomInviteResponse; } as InviteResponse;
}; };

View File

@ -8,14 +8,14 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface RoomOpenRequest extends ProtocolRequest { export interface OpenRequest extends ProtocolRequest {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1n. 초대자 userSeq(n)... // 1n. 초대자 userSeq(n)...
userSeqs: number[]; userSeqs: number[];
} }
export interface RoomOpenResponse extends ProtocolResponse { export interface OpenResponse extends ProtocolResponse {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방SEQ(s) // 1. 대화방SEQ(s)
@ -24,9 +24,7 @@ export interface RoomOpenResponse extends ProtocolResponse {
newRoom: boolean; newRoom: boolean;
} }
export const encodeRoomOpen: ProtocolEncoder<RoomOpenRequest> = ( export const encodeOpen: ProtocolEncoder<OpenRequest> = (req: OpenRequest) => {
req: RoomOpenRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.divCd }); bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
@ -37,17 +35,17 @@ export const encodeRoomOpen: ProtocolEncoder<RoomOpenRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomOpen: ProtocolDecoder<RoomOpenResponse> = ( export const decodeOpen: ProtocolDecoder<OpenResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
divCd: message.bodyList[0], divCd: message.bodyList[0],
roomSeq: message.bodyList[1], roomSeq: message.bodyList[1],
newRoom: message.bodyList[2] === 'Y' ? true : false newRoom: message.bodyList[2] === 'Y' ? true : false
} as RoomOpenResponse; } as OpenResponse;
}; };
export interface RoomOpen2Request extends ProtocolRequest { export interface Open2Request extends ProtocolRequest {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -56,7 +54,7 @@ export interface RoomOpen2Request extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export interface RoomOpen2Response extends ProtocolResponse { export interface Open2Response extends ProtocolResponse {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -67,8 +65,8 @@ export interface RoomOpen2Response extends ProtocolResponse {
newRoom: boolean; newRoom: boolean;
} }
export const encodeRoomOpen2: ProtocolEncoder<RoomOpen2Request> = ( export const encodeOpen2: ProtocolEncoder<Open2Request> = (
req: RoomOpen2Request req: Open2Request
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -81,7 +79,7 @@ export const encodeRoomOpen2: ProtocolEncoder<RoomOpen2Request> = (
return bodyList; return bodyList;
}; };
export const decodeRoomOpen2: ProtocolDecoder<RoomOpen2Response> = ( export const decodeOpen2: ProtocolDecoder<Open2Response> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
@ -89,10 +87,10 @@ export const decodeRoomOpen2: ProtocolDecoder<RoomOpen2Response> = (
roomName: message.bodyList[1], roomName: message.bodyList[1],
roomSeq: message.bodyList[2], roomSeq: message.bodyList[2],
newRoom: message.bodyList[3] === 'Y' ? true : false newRoom: message.bodyList[3] === 'Y' ? true : false
} as RoomOpen2Response; } as Open2Response;
}; };
export interface RoomOpen3Request extends ProtocolRequest { export interface Open3Request extends ProtocolRequest {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -105,7 +103,7 @@ export interface RoomOpen3Request extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export interface RoomOpen3Response extends ProtocolResponse { export interface Open3Response extends ProtocolResponse {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -120,8 +118,8 @@ export interface RoomOpen3Response extends ProtocolResponse {
timerRoomInterval: number; timerRoomInterval: number;
} }
export const encodeRoomOpen3: ProtocolEncoder<RoomOpen3Request> = ( export const encodeOpen3: ProtocolEncoder<Open3Request> = (
req: RoomOpen3Request req: Open3Request
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -142,7 +140,7 @@ export const encodeRoomOpen3: ProtocolEncoder<RoomOpen3Request> = (
return bodyList; return bodyList;
}; };
export const decodeRoomOpen3: ProtocolDecoder<RoomOpen3Response> = ( export const decodeOpen3: ProtocolDecoder<Open3Response> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
@ -152,10 +150,10 @@ export const decodeRoomOpen3: ProtocolDecoder<RoomOpen3Response> = (
newRoom: message.bodyList[3] === 'Y' ? true : false, newRoom: message.bodyList[3] === 'Y' ? true : false,
isTimerRoom: message.bodyList[4] === 'Y' ? true : false, isTimerRoom: message.bodyList[4] === 'Y' ? true : false,
timerRoomInterval: message.bodyList[5] || 0 timerRoomInterval: message.bodyList[5] || 0
} as RoomOpen3Response; } as Open3Response;
}; };
export interface RoomOpen4Request extends ProtocolRequest { export interface Open4Request extends ProtocolRequest {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -168,7 +166,7 @@ export interface RoomOpen4Request extends ProtocolRequest {
userSeqs: number[]; userSeqs: number[];
} }
export interface RoomOpen4Response extends ProtocolResponse { export interface Open4Response extends ProtocolResponse {
// 0. 구분자 // 0. 구분자
divCd: string; divCd: string;
// 1. 대화방제목(s) // 1. 대화방제목(s)
@ -183,8 +181,8 @@ export interface RoomOpen4Response extends ProtocolResponse {
timerRoomInterval: number; timerRoomInterval: number;
} }
export const encodeRoomOpen4: ProtocolEncoder<RoomOpen4Request> = ( export const encodeOpen4: ProtocolEncoder<Open4Request> = (
req: RoomOpen4Request req: Open4Request
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -205,7 +203,7 @@ export const encodeRoomOpen4: ProtocolEncoder<RoomOpen4Request> = (
return bodyList; return bodyList;
}; };
export const decodeRoomOpen4: ProtocolDecoder<RoomOpen4Response> = ( export const decodeOpen4: ProtocolDecoder<Open4Response> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
@ -216,5 +214,5 @@ export const decodeRoomOpen4: ProtocolDecoder<RoomOpen4Response> = (
isTimerRoom: message.bodyList[4] === 'Y' ? true : false, isTimerRoom: message.bodyList[4] === 'Y' ? true : false,
timerRoomInterval: timerRoomInterval:
message.bodyList[4] !== 'Y' ? 0 : message.bodyList[5] || 0 message.bodyList[4] !== 'Y' ? 0 : message.bodyList[5] || 0
} as RoomOpen4Response; } as Open4Response;
}; };

View File

@ -8,7 +8,7 @@ import {
ProtocolMessage ProtocolMessage
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface RoomUpdateRequest extends ProtocolRequest { export interface UpdateRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 대화방제목(s) // 대화방제목(s)
@ -19,7 +19,7 @@ export interface RoomUpdateRequest extends ProtocolRequest {
isSyncAll: boolean; isSyncAll: boolean;
} }
export interface RoomUpdateResponse extends ProtocolResponse { export interface UpdateResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 대화방제목(s) // 대화방제목(s)
@ -30,8 +30,8 @@ export interface RoomUpdateResponse extends ProtocolResponse {
isSyncAll: boolean; isSyncAll: boolean;
} }
export const encodeRoomUpdate: ProtocolEncoder<RoomUpdateRequest> = ( export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
req: RoomUpdateRequest req: UpdateRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -48,7 +48,7 @@ export const encodeRoomUpdate: ProtocolEncoder<RoomUpdateRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomUpdate: ProtocolDecoder<RoomUpdateResponse> = ( export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
@ -56,26 +56,26 @@ export const decodeRoomUpdate: ProtocolDecoder<RoomUpdateResponse> = (
roomName: message.bodyList[1], roomName: message.bodyList[1],
isAlarm: message.bodyList[2] === 'Y' ? true : false, isAlarm: message.bodyList[2] === 'Y' ? true : false,
isSyncAll: message.bodyList[3] === 'Y' ? true : false isSyncAll: message.bodyList[3] === 'Y' ? true : false
} as RoomUpdateResponse; } as UpdateResponse;
}; };
export interface RoomUpdateTimerSetRequest extends ProtocolRequest { export interface UpdateTimerSetRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 타이머시간(n) // 타이머시간(n)
timerInterval: number; timerInterval: number;
} }
export interface RoomUpdateTimerSetResponse extends ProtocolResponse { export interface UpdateTimerSetResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 타이머시간(n) // 타이머시간(n)
timerInterval: number; timerInterval: number;
} }
export const encodeRoomUpdateTimerSet: ProtocolEncoder< export const encodeUpdateTimerSet: ProtocolEncoder<UpdateTimerSetRequest> = (
RoomUpdateTimerSetRequest req: UpdateTimerSetRequest
> = (req: RoomUpdateTimerSetRequest) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq });
@ -83,16 +83,16 @@ export const encodeRoomUpdateTimerSet: ProtocolEncoder<
return bodyList; return bodyList;
}; };
export const decodeRoomUpdateTimerSet: ProtocolDecoder< export const decodeUpdateTimerSet: ProtocolDecoder<UpdateTimerSetResponse> = (
RoomUpdateTimerSetResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
timerInterval: message.bodyList[1] || 0 timerInterval: message.bodyList[1] || 0
} as RoomUpdateTimerSetResponse; } as UpdateTimerSetResponse;
}; };
export interface RoomUpdateFontRequest extends ProtocolRequest { export interface UpdateFontRequest extends ProtocolRequest {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 폰트색(s) cf)0x000000 형태의 스트링 // 폰트색(s) cf)0x000000 형태의 스트링
@ -101,7 +101,7 @@ export interface RoomUpdateFontRequest extends ProtocolRequest {
senderSeq: number; senderSeq: number;
} }
export interface RoomUpdateFontResponse extends ProtocolResponse { export interface UpdateFontResponse extends ProtocolResponse {
// 대화방SEQ(s) // 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 폰트색(s) cf)0x000000 형태의 스트링 // 폰트색(s) cf)0x000000 형태의 스트링
@ -110,8 +110,8 @@ export interface RoomUpdateFontResponse extends ProtocolResponse {
senderSeq: number; senderSeq: number;
} }
export const encodeRoomUpdateFont: ProtocolEncoder<RoomUpdateFontRequest> = ( export const encodeUpdateFont: ProtocolEncoder<UpdateFontRequest> = (
req: RoomUpdateFontRequest req: UpdateFontRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -121,22 +121,22 @@ export const encodeRoomUpdateFont: ProtocolEncoder<RoomUpdateFontRequest> = (
return bodyList; return bodyList;
}; };
export const decodeRoomUpdateFont: ProtocolDecoder<RoomUpdateFontResponse> = ( export const decodeUpdateFont: ProtocolDecoder<UpdateFontResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
fontColor: message.bodyList[1], fontColor: message.bodyList[1],
senderSeq: message.bodyList[2] senderSeq: message.bodyList[2]
} as RoomUpdateFontResponse; } as UpdateFontResponse;
}; };
export const decodeRoomUpdateFontNotification: ProtocolDecoder< export const decodeUpdateFontNotification: ProtocolDecoder<
RoomUpdateFontResponse UpdateFontResponse
> = (message: ProtocolMessage) => { > = (message: ProtocolMessage) => {
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
fontColor: message.bodyList[1], fontColor: message.bodyList[1],
senderSeq: message.bodyList[2] senderSeq: message.bodyList[2]
} as RoomUpdateFontResponse; } as UpdateFontResponse;
}; };

View File

@ -25,70 +25,70 @@ import {
SSVC_TYPE_ROOM_FONT_UPD_REQ SSVC_TYPE_ROOM_FONT_UPD_REQ
} from '../types/service'; } from '../types/service';
import { import {
RoomOpenRequest, OpenRequest,
encodeRoomOpen, encodeOpen,
decodeRoomOpen, decodeOpen,
RoomOpenResponse, OpenResponse,
RoomOpen2Request, Open2Request,
RoomOpen2Response, Open2Response,
decodeRoomOpen2, decodeOpen2,
encodeRoomOpen2, encodeOpen2,
RoomOpen3Request, Open3Request,
RoomOpen3Response, Open3Response,
encodeRoomOpen3, encodeOpen3,
decodeRoomOpen3, decodeOpen3,
RoomOpen4Request, Open4Request,
RoomOpen4Response, Open4Response,
encodeRoomOpen4, encodeOpen4,
decodeRoomOpen4 decodeOpen4
} from '../models/open'; } from '../models/open';
import { import {
RoomInviteRequest, InviteRequest,
RoomInviteResponse, InviteResponse,
encodeRoomInvite, encodeInvite,
decodeRoomInvite decodeInvite
} from '../models/invite'; } from '../models/invite';
import { import {
RoomInfoRequest, InfoRequest,
RoomInfoResponse, InfoResponse,
RoomInfoDataResponse, InfoData,
RoomUserShortDataResponse, UserShortData,
RoomUserDataResponse, UserData,
encodeRoomInfo, encodeInfo,
decodeRoomInfoData, decodeInfoData,
decodeRoomInfo, decodeInfo,
decodeRoomUserShortData, decodeUserShortData,
decodeRoomUserData, decodeUserData,
RoomUserStatusOfflineRequest, UserStatusOfflineRequest,
RoomUserStatusOfflineResponse, UserStatusOfflineResponse,
encodeRoomUserStatusOffline, encodeUserStatusOffline,
decodeRoomUserStatusOffline decodeUserStatusOffline
} from '../models/info'; } from '../models/info';
import { import {
RoomExitRequest, ExitRequest,
RoomExitResponse, ExitResponse,
encodeRoomExit, encodeExit,
decodeRoomExit, decodeExit,
RoomExitAllRequest, ExitAllRequest,
encodeRoomAllExit, encodeAllExit,
RoomExitForcingRequest, ExitForcingRequest,
RoomExitForcingResponse, ExitForcingResponse,
encodeRoomExitForcing, encodeExitForcing,
decodeRoomExitForcing decodeExitForcing
} from '../models/exit'; } from '../models/exit';
import { import {
RoomUpdateRequest, UpdateRequest,
RoomUpdateResponse, UpdateResponse,
encodeRoomUpdate, encodeUpdate,
decodeRoomUpdate, decodeUpdate,
RoomUpdateTimerSetRequest, UpdateTimerSetRequest,
RoomUpdateTimerSetResponse, UpdateTimerSetResponse,
encodeRoomUpdateTimerSet, encodeUpdateTimerSet,
decodeRoomUpdateTimerSet, decodeUpdateTimerSet,
RoomUpdateFontRequest, UpdateFontRequest,
RoomUpdateFontResponse, UpdateFontResponse,
encodeRoomUpdateFont, encodeUpdateFont,
decodeRoomUpdateFont decodeUpdateFont
} from '../models/update'; } from '../models/update';
@Injectable({ @Injectable({
@ -97,169 +97,159 @@ import {
export class RoomProtocolService { export class RoomProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public roomOpen(req: RoomOpenRequest): Observable<RoomOpenResponse> { public open(req: OpenRequest): Observable<OpenResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeRoomOpen(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeOpen(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeRoomOpen(res)) map(res => decodeOpen(res))
); );
} }
public roomOpen2(req: RoomOpen2Request): Observable<RoomOpen2Response> { public open2(req: Open2Request): Observable<Open2Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeOpen2(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeRoomOpen2(res)) map(res => decodeOpen2(res))
); );
} }
public roomOpen3(req: RoomOpen3Request): Observable<RoomOpen3Response> { public open3(req: Open3Request): Observable<Open3Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeOpen3(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeRoomOpen3(res)) map(res => decodeOpen3(res))
); );
} }
public roomOpen4(req: RoomOpen4Request): Observable<RoomOpen4Response> { public open4(req: Open4Request): Observable<Open4Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeOpen4(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeRoomOpen4(res)) map(res => decodeOpen4(res))
); );
} }
public roomInvite(req: RoomInviteRequest): Observable<RoomInviteResponse> { public invite(req: InviteRequest): Observable<InviteResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INVITE_REQ, ...encodeRoomInvite(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INVITE_REQ, ...encodeInvite(req))
.pipe( .pipe(
take(1), take(1),
map(res => decodeRoomInvite(res)) map(res => decodeInvite(res))
); );
} }
public roomInfo( public info(
req: RoomInfoRequest req: InfoRequest
): Observable< ): Observable<InfoResponse | InfoData | UserShortData | UserData> {
| RoomInfoResponse
| RoomInfoDataResponse
| RoomUserShortDataResponse
| RoomUserDataResponse
> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INFO_REQ, ...encodeRoomInfo(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_INFO_REQ, ...encodeInfo(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_ROOM_INFO_RES !== res.subServiceType, true), takeWhile(res => SSVC_TYPE_ROOM_INFO_RES !== res.subServiceType, true),
map(res => { map(res => {
if (SSVC_TYPE_ROOM_INFO_ROOM === res.subServiceType) { if (SSVC_TYPE_ROOM_INFO_ROOM === res.subServiceType) {
return decodeRoomInfoData(res); return { ...decodeInfoData(res), Type: SSVC_TYPE_ROOM_INFO_ROOM };
} else if (SSVC_TYPE_ROOM_INFO_USER === res.subServiceType) { } else if (SSVC_TYPE_ROOM_INFO_USER === res.subServiceType) {
return decodeRoomUserShortData(res); return {
...decodeUserShortData(res),
Type: SSVC_TYPE_ROOM_INFO_USER
};
} else if (SSVC_TYPE_ROOM_INFO_USER2 === res.subServiceType) { } else if (SSVC_TYPE_ROOM_INFO_USER2 === res.subServiceType) {
return decodeRoomUserData(res); return { ...decodeUserData(res), Type: SSVC_TYPE_ROOM_INFO_USER2 };
} }
return decodeRoomInfo(res); return { ...decodeInfo(res), Type: SSVC_TYPE_ROOM_INFO_RES };
}) })
); );
} }
public roomUserStatusOffline( public userStatusOffline(
req: RoomUserStatusOfflineRequest req: UserStatusOfflineRequest
): Observable<RoomUserStatusOfflineResponse> { ): Observable<UserStatusOfflineResponse> {
return this.protocolService return this.protocolService
.call( .call(
SVC_TYPE_ROOM, SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_USER_STATUS_REQ, SSVC_TYPE_ROOM_USER_STATUS_REQ,
...encodeRoomUserStatusOffline(req) ...encodeUserStatusOffline(req)
) )
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomUserStatusOffline(res); return decodeUserStatusOffline(res);
}) })
); );
} }
public roomExit(req: RoomExitRequest): Observable<RoomExitResponse> { public exit(req: ExitRequest): Observable<ExitResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_EXIT_REQ, ...encodeRoomExit(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_EXIT_REQ, ...encodeExit(req))
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomExit(res); return decodeExit(res);
}) })
); );
} }
public roomExitAll(req: RoomExitAllRequest): Observable<void> { public exitAll(req: ExitAllRequest): Observable<void> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_EXIT_ALL_REQ, ...encodeAllExit(req))
SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_EXIT_ALL_REQ,
...encodeRoomAllExit(req)
)
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
}) })
); );
} }
public roomExitForcing( public exitForcing(req: ExitForcingRequest): Observable<ExitForcingResponse> {
req: RoomExitForcingRequest
): Observable<RoomExitForcingResponse> {
return this.protocolService return this.protocolService
.call( .call(
SVC_TYPE_ROOM, SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_EXIT_FORCING_REQ, SSVC_TYPE_ROOM_EXIT_FORCING_REQ,
...encodeRoomExitForcing(req) ...encodeExitForcing(req)
) )
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomExitForcing(res); return decodeExitForcing(res);
}) })
); );
} }
public roomUpdate(req: RoomUpdateRequest): Observable<RoomUpdateResponse> { public update(req: UpdateRequest): Observable<UpdateResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_UPD_REQ, ...encodeRoomUpdate(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_UPD_REQ, ...encodeUpdate(req))
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomUpdate(res); return decodeUpdate(res);
}) })
); );
} }
public roomUpdateTimerSet( public updateTimerSet(
req: RoomUpdateTimerSetRequest req: UpdateTimerSetRequest
): Observable<RoomUpdateTimerSetResponse> { ): Observable<UpdateTimerSetResponse> {
return this.protocolService return this.protocolService
.call( .call(
SVC_TYPE_ROOM, SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_INFO_UPD_REQ, SSVC_TYPE_ROOM_INFO_UPD_REQ,
...encodeRoomUpdateTimerSet(req) ...encodeUpdateTimerSet(req)
) )
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomUpdateTimerSet(res); return decodeUpdateTimerSet(res);
}) })
); );
} }
public roomUpdateFont( public updateFont(req: UpdateFontRequest): Observable<UpdateFontResponse> {
req: RoomUpdateFontRequest
): Observable<RoomUpdateFontResponse> {
return this.protocolService return this.protocolService
.call( .call(
SVC_TYPE_ROOM, SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_FONT_UPD_REQ, SSVC_TYPE_ROOM_FONT_UPD_REQ,
...encodeRoomUpdateFont(req) ...encodeUpdateFont(req)
) )
.pipe( .pipe(
map(res => { map(res => {
take(1); take(1);
return decodeRoomUpdateFont(res); return decodeUpdateFont(res);
}) })
); );
} }

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map, take, takeWhile } from 'rxjs/operators'; import { map, take } from 'rxjs/operators';
import { import {
UserPasswordSetRequest, UserPasswordSetRequest,
UserPasswordSetResponse, UserPasswordSetResponse,