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

View File

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

View File

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

View File

@ -1,17 +1,17 @@
import { Injectable } from '@angular/core';
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 {
BuddyRequest,
BuddyResponse,
BuddyDataResponse,
BuddyData,
encodeBuddy,
decodeBuddyData,
decodeBuddy,
decodeBuddyDataDetail
decodeBuddyDetailData
} from '../models/buddy';
import {
SVC_TYPE_SYNC_BUDDY,
@ -43,21 +43,21 @@ import {
import {
GroupRequest,
GroupResponse,
GroupDataResponse,
GroupData,
encodeGroup,
decodeGroupDataDetail,
decodeGroupDetailData,
decodeGroup,
decodeGroupData,
GroupDataDetailResponse
GroupDetailData
} from '../models/group';
import {
RoomRequest,
RoomResponse,
encodeRoom,
decodeRoom,
RoomUserDataResponse,
RoomUserDataDetailResponse,
RoomDataResponse,
RoomUserData,
RoomUserDetailData,
RoomData,
decodeRoomData,
decodeRoomUserData,
decodeRoomUserDataDetail
@ -69,26 +69,28 @@ import {
export class SyncProtocolService {
constructor(private protocolService: ProtocolService) {}
public buddy(
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
public buddy(req: BuddyRequest): Observable<BuddyResponse | BuddyData> {
return this.protocolService
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY_REQ, ...encodeBuddy(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType, true),
map(res => {
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(
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
public buddy2(req: BuddyRequest): Observable<BuddyResponse | BuddyData> {
return this.protocolService
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY2_REQ, ...encodeBuddy(req))
.pipe(
@ -98,34 +100,44 @@ export class SyncProtocolService {
),
map(res => {
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(
req: GroupRequest
): Observable<GroupResponse | GroupDataResponse> {
public group(req: GroupRequest): Observable<GroupResponse | GroupData> {
return this.protocolService
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ, ...encodeGroup(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType, true),
map(res => {
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
): Observable<GroupResponse | GroupDataDetailResponse> {
): Observable<GroupResponse | GroupDetailData> {
return this.protocolService
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ2, ...encodeGroup(req))
.pipe(
@ -135,62 +147,82 @@ export class SyncProtocolService {
),
map(res => {
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
): Observable<
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
): Observable<RoomResponse | RoomData | RoomUserData | RoomUserDetailData> {
return this.protocolService
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeRoom(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType, true),
map(res => {
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) {
return decodeRoomUserData(res);
return {
...decodeRoomUserData(res),
Type: SSVC_TYPE_SYNC_ROOM_USER
};
} 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
): Observable<
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
): Observable<RoomResponse | RoomData | RoomUserData | RoomUserDetailData> {
return this.protocolService
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM2_REQ, ...encodeRoom(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType, true),
map(res => {
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) {
return decodeRoomUserData(res);
return {
...decodeRoomUserData(res),
Type: SSVC_TYPE_SYNC_ROOM2_USER
};
} 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
};
})
);
}