This commit is contained in:
병준 박 2019-09-25 15:52:40 +09:00
parent 184f2365bb
commit 1c2c457187
4 changed files with 111 additions and 76 deletions

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 { UserInfo } from '../types/userInfo'; import { UserInfo } from '../types/userInfo';
@ -24,12 +25,12 @@ export interface BuddyRequest extends ProtocolRequest {
syncDate: string; syncDate: string;
} }
export interface BuddyDataResponse extends ProtocolResponse { export interface BuddyData extends ProtocolStream {
// n. {동료정보-S}... // n. {동료정보-S}...
buddyInfos: BuddyInfo[]; buddyInfos: BuddyInfo[];
} }
export interface BuddyDataDetailResponse extends ProtocolResponse { export interface BuddyDetailData extends ProtocolStream {
// n. {동료정보-S}... // n. {동료정보-S}...
buddyInfos: UserInfo[]; buddyInfos: UserInfo[];
} }
@ -56,7 +57,7 @@ export const decodeBuddy: ProtocolDecoder<BuddyResponse> = (
} as BuddyResponse; } as BuddyResponse;
}; };
export const decodeBuddyData: ProtocolDecoder<BuddyDataResponse> = ( export const decodeBuddyData: ProtocolDecoder<BuddyData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const buddyInfos: BuddyInfo[] = []; const buddyInfos: BuddyInfo[] = [];
@ -70,10 +71,10 @@ export const decodeBuddyData: ProtocolDecoder<BuddyDataResponse> = (
}); });
return { return {
buddyInfos buddyInfos
} as BuddyDataResponse; } as BuddyData;
}; };
export const decodeBuddyDataDetail: ProtocolDecoder<BuddyDataDetailResponse> = ( export const decodeBuddyDetailData: ProtocolDecoder<BuddyDetailData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const buddyInfos: UserInfo[] = []; const buddyInfos: UserInfo[] = [];
@ -114,5 +115,5 @@ export const decodeBuddyDataDetail: ProtocolDecoder<BuddyDataDetailResponse> = (
}); });
return { return {
buddyInfos buddyInfos
} as BuddyDataDetailResponse; } as BuddyDetailData;
}; };

View File

@ -6,7 +6,8 @@ import {
PacketBodyValue, PacketBodyValue,
ProtocolDecoder, ProtocolDecoder,
ProtocolMessage, ProtocolMessage,
BodyStringDivider BodyStringDivider,
ProtocolStream
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
export interface GroupInfo { export interface GroupInfo {
@ -24,12 +25,12 @@ export interface GroupRequest extends ProtocolRequest {
syncDate: string; syncDate: string;
} }
export interface GroupDataResponse extends ProtocolResponse { export interface GroupData extends ProtocolStream {
// n. {동료그룹정보}... // n. {동료그룹정보}...
groupInfos: GroupInfo[]; groupInfos: GroupInfo[];
} }
export interface GroupDataDetailResponse extends ProtocolResponse { export interface GroupDetailData extends ProtocolStream {
// 그룹SEQ(n) // 그룹SEQ(n)
seq: number; seq: number;
// 그룹이름(s) // 그룹이름(s)
@ -62,7 +63,7 @@ export const decodeGroup: ProtocolDecoder<GroupResponse> = (
} as GroupResponse; } as GroupResponse;
}; };
export const decodeGroupData: ProtocolDecoder<GroupDataResponse> = ( export const decodeGroupData: ProtocolDecoder<GroupData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const groupInfos: GroupInfo[] = []; const groupInfos: GroupInfo[] = [];
@ -78,10 +79,10 @@ export const decodeGroupData: ProtocolDecoder<GroupDataResponse> = (
return { return {
groupInfos groupInfos
} as GroupDataResponse; } as GroupData;
}; };
export const decodeGroupDataDetail: ProtocolDecoder<GroupDataDetailResponse> = ( export const decodeGroupDetailData: ProtocolDecoder<GroupDetailData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
let userSeqs: number[] = []; let userSeqs: number[] = [];
@ -97,5 +98,5 @@ export const decodeGroupDataDetail: ProtocolDecoder<GroupDataDetailResponse> = (
isActive: message.bodyList[2] === 'Y' ? true : false, isActive: message.bodyList[2] === 'Y' ? true : false,
// 사용자SEQ(n)1 // 사용자SEQ(n)1
userSeqs userSeqs
} as GroupDataDetailResponse; } as GroupDetailData;
}; };

View File

@ -7,7 +7,8 @@ import {
PacketBodyValue, PacketBodyValue,
ProtocolDecoder, ProtocolDecoder,
ProtocolMessage, ProtocolMessage,
BodyStringDivider BodyStringDivider,
ProtocolStream
} from '@ucap-webmessenger/protocol'; } from '@ucap-webmessenger/protocol';
import { import {
RoomInfo, RoomInfo,
@ -25,19 +26,19 @@ export interface RoomRequest extends ProtocolRequest {
localeCode: LocaleCode; localeCode: LocaleCode;
} }
export interface RoomDataResponse extends ProtocolResponse { export interface RoomData extends ProtocolStream {
// n. {대화방정보}... // n. {대화방정보}...
roomInfos: RoomInfo[]; roomInfos: RoomInfo[];
} }
export interface RoomUserDataResponse extends ProtocolResponse { export interface RoomUserData extends ProtocolStream {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보} // 1n. {참여자정보}
userInfos: UserInfoShort[]; userInfos: UserInfoShort[];
} }
export interface RoomUserDataDetailResponse extends ProtocolResponse { export interface RoomUserDetailData extends ProtocolStream {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보-D} // 1n. {참여자정보-D}
@ -65,7 +66,7 @@ export const decodeRoom: ProtocolDecoder<RoomResponse> = (
} as RoomResponse; } as RoomResponse;
}; };
export const decodeRoomData: ProtocolDecoder<RoomDataResponse> = ( export const decodeRoomData: ProtocolDecoder<RoomData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const roomInfos: RoomInfo[] = []; const roomInfos: RoomInfo[] = [];
@ -93,10 +94,10 @@ export const decodeRoomData: ProtocolDecoder<RoomDataResponse> = (
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
roomInfos roomInfos
} as RoomDataResponse; } as RoomData;
}; };
export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = ( export const decodeRoomUserData: ProtocolDecoder<RoomUserData> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const userInfos: UserInfoShort[] = []; const userInfos: UserInfoShort[] = [];
@ -123,12 +124,12 @@ export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = (
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as RoomUserDataResponse; } as RoomUserData;
}; };
export const decodeRoomUserDataDetail: ProtocolDecoder< export const decodeRoomUserDataDetail: ProtocolDecoder<RoomUserDetailData> = (
RoomUserDataDetailResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
const userInfos: UserInfo[] = []; const userInfos: UserInfo[] = [];
message.bodyList.slice(1).forEach(userInfo => { message.bodyList.slice(1).forEach(userInfo => {
const info = userInfo.split(BodyStringDivider); const info = userInfo.split(BodyStringDivider);
@ -169,5 +170,5 @@ export const decodeRoomUserDataDetail: ProtocolDecoder<
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as RoomUserDataDetailResponse; } as RoomUserDetailData;
}; };

View File

@ -1,17 +1,17 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map, take, takeWhile, takeUntil } from 'rxjs/operators'; import { map, takeWhile } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import { import {
BuddyRequest, BuddyRequest,
BuddyResponse, BuddyResponse,
BuddyDataResponse, BuddyData,
encodeBuddy, encodeBuddy,
decodeBuddyData, decodeBuddyData,
decodeBuddy, decodeBuddy,
decodeBuddyDataDetail decodeBuddyDetailData
} from '../models/buddy'; } from '../models/buddy';
import { import {
SVC_TYPE_SYNC_BUDDY, SVC_TYPE_SYNC_BUDDY,
@ -43,21 +43,21 @@ import {
import { import {
GroupRequest, GroupRequest,
GroupResponse, GroupResponse,
GroupDataResponse, GroupData,
encodeGroup, encodeGroup,
decodeGroupDataDetail, decodeGroupDetailData,
decodeGroup, decodeGroup,
decodeGroupData, decodeGroupData,
GroupDataDetailResponse GroupDetailData
} from '../models/group'; } from '../models/group';
import { import {
RoomRequest, RoomRequest,
RoomResponse, RoomResponse,
encodeRoom, encodeRoom,
decodeRoom, decodeRoom,
RoomUserDataResponse, RoomUserData,
RoomUserDataDetailResponse, RoomUserDetailData,
RoomDataResponse, RoomData,
decodeRoomData, decodeRoomData,
decodeRoomUserData, decodeRoomUserData,
decodeRoomUserDataDetail decodeRoomUserDataDetail
@ -69,26 +69,28 @@ import {
export class SyncProtocolService { export class SyncProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public buddy( public buddy(req: BuddyRequest): Observable<BuddyResponse | BuddyData> {
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY_REQ, ...encodeBuddy(req)) .call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY_REQ, ...encodeBuddy(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType, true), takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType, true),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) {
return decodeBuddyData(res); return {
...decodeBuddyData(res),
Type: SSVC_TYPE_SYNC_BUDDY_DATA
};
} }
return decodeBuddy(res); return {
...decodeBuddy(res),
Type: SSVC_TYPE_SYNC_BUDDY_RES
};
}) })
); );
} }
public buddy2( public buddy2(req: BuddyRequest): Observable<BuddyResponse | BuddyData> {
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY2_REQ, ...encodeBuddy(req)) .call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY2_REQ, ...encodeBuddy(req))
.pipe( .pipe(
@ -98,34 +100,44 @@ export class SyncProtocolService {
), ),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) {
return decodeBuddyDataDetail(res); return {
...decodeBuddyDetailData(res),
Type: SSVC_TYPE_SYNC_BUDDY2_DATA
};
} }
return decodeBuddy(res); return {
...decodeBuddy(res),
Type: SSVC_TYPE_SYNC_BUDDY2_RES
};
}) })
); );
} }
public syncGroup( public group(req: GroupRequest): Observable<GroupResponse | GroupData> {
req: GroupRequest
): Observable<GroupResponse | GroupDataResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ, ...encodeGroup(req)) .call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ, ...encodeGroup(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType, true), takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType, true),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) {
return decodeGroupData(res); return {
...decodeGroupData(res),
Type: SSVC_TYPE_SYNC_GROUP_DATA
};
} }
return decodeGroup(res); return {
...decodeGroup(res),
Type: SSVC_TYPE_SYNC_GROUP_RES
};
}) })
); );
} }
public syncGroup2( public group2(
req: GroupRequest req: GroupRequest
): Observable<GroupResponse | GroupDataDetailResponse> { ): Observable<GroupResponse | GroupDetailData> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ2, ...encodeGroup(req)) .call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ2, ...encodeGroup(req))
.pipe( .pipe(
@ -135,62 +147,82 @@ export class SyncProtocolService {
), ),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) { if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) {
return decodeGroupDataDetail(res); return {
...decodeGroupDetailData(res),
Type: SSVC_TYPE_SYNC_GROUP_DATA2
};
} }
return decodeGroup(res); return {
...decodeGroup(res),
Type: SSVC_TYPE_SYNC_GROUP_RES2
};
}) })
); );
} }
public syncRoom( public room(
req: RoomRequest req: RoomRequest
): Observable< ): Observable<RoomResponse | RoomData | RoomUserData | RoomUserDetailData> {
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeRoom(req)) .call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeRoom(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType, true), takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType, true),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) {
return decodeRoomData(res); return {
...decodeRoomData(res),
Type: SSVC_TYPE_SYNC_ROOM_DATA
};
} else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) {
return decodeRoomUserData(res); return {
...decodeRoomUserData(res),
Type: SSVC_TYPE_SYNC_ROOM_USER
};
} else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) {
return decodeRoomUserDataDetail(res); return {
...decodeRoomUserDataDetail(res),
Type: SSVC_TYPE_SYNC_ROOM_USER2
};
} }
return decodeRoom(res); return {
...decodeRoom(res),
Type: SSVC_TYPE_SYNC_ROOM_RES
};
}) })
); );
} }
public syncRoom2( public room2(
req: RoomRequest req: RoomRequest
): Observable< ): Observable<RoomResponse | RoomData | RoomUserData | RoomUserDetailData> {
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM2_REQ, ...encodeRoom(req)) .call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM2_REQ, ...encodeRoom(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType, true), takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType, true),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) {
return decodeRoomData(res); return {
...decodeRoomData(res),
Type: SSVC_TYPE_SYNC_ROOM2_DATA
};
} else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) {
return decodeRoomUserData(res); return {
...decodeRoomUserData(res),
Type: SSVC_TYPE_SYNC_ROOM2_USER
};
} else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) {
return decodeRoomUserDataDetail(res); return {
...decodeRoomUserDataDetail(res),
Type: SSVC_TYPE_SYNC_ROOM2_USER2
};
} }
return decodeRoom(res); return {
...decodeRoom(res),
Type: SSVC_TYPE_SYNC_ROOM2_RES
};
}) })
); );
} }