This commit is contained in:
병준 박 2019-09-25 14:48:36 +09:00
parent d6c57da8a8
commit 17e3fdd790
4 changed files with 112 additions and 134 deletions

View File

@ -19,28 +19,28 @@ export interface BuddyInfo {
isBuddy: boolean; isBuddy: boolean;
} }
export interface SyncBuddyRequest extends ProtocolRequest { export interface BuddyRequest extends ProtocolRequest {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
} }
export interface SyncBuddyDataResponse extends ProtocolResponse { export interface BuddyDataResponse extends ProtocolResponse {
// n. {동료정보-S}... // n. {동료정보-S}...
buddyInfos: BuddyInfo[]; buddyInfos: BuddyInfo[];
} }
export interface SyncBuddyDataDetailResponse extends ProtocolResponse { export interface BuddyDataDetailResponse extends ProtocolResponse {
// n. {동료정보-S}... // n. {동료정보-S}...
buddyInfos: UserInfo[]; buddyInfos: UserInfo[];
} }
export interface SyncBuddyResponse extends ProtocolResponse { export interface BuddyResponse extends ProtocolResponse {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
} }
export const encodeSyncBuddy: ProtocolEncoder<SyncBuddyRequest> = ( export const encodeBuddy: ProtocolEncoder<BuddyRequest> = (
req: SyncBuddyRequest req: BuddyRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -48,15 +48,15 @@ export const encodeSyncBuddy: ProtocolEncoder<SyncBuddyRequest> = (
return bodyList; return bodyList;
}; };
export const decodeSyncBuddy: ProtocolDecoder<SyncBuddyResponse> = ( export const decodeBuddy: ProtocolDecoder<BuddyResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
syncDate: message.bodyList[0] syncDate: message.bodyList[0]
} as SyncBuddyResponse; } as BuddyResponse;
}; };
export const decodeSyncBuddyData: ProtocolDecoder<SyncBuddyDataResponse> = ( export const decodeBuddyData: ProtocolDecoder<BuddyDataResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const buddyInfos: BuddyInfo[] = []; const buddyInfos: BuddyInfo[] = [];
@ -70,12 +70,12 @@ export const decodeSyncBuddyData: ProtocolDecoder<SyncBuddyDataResponse> = (
}); });
return { return {
buddyInfos buddyInfos
} as SyncBuddyDataResponse; } as BuddyDataResponse;
}; };
export const decodeSyncBuddyDataDetail: ProtocolDecoder< export const decodeBuddyDataDetail: ProtocolDecoder<BuddyDataDetailResponse> = (
SyncBuddyDataDetailResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
const buddyInfos: UserInfo[] = []; const buddyInfos: UserInfo[] = [];
message.bodyList.forEach(buddyinfo => { message.bodyList.forEach(buddyinfo => {
const info = buddyinfo.split(BodyStringDivider); const info = buddyinfo.split(BodyStringDivider);
@ -114,5 +114,5 @@ export const decodeSyncBuddyDataDetail: ProtocolDecoder<
}); });
return { return {
buddyInfos buddyInfos
} as SyncBuddyDataDetailResponse; } as BuddyDataDetailResponse;
}; };

View File

@ -19,17 +19,17 @@ export interface GroupInfo {
// 사용자SEQ(s) // 사용자SEQ(s)
userSeqStr: string; userSeqStr: string;
} }
export interface SyncGroupRequest extends ProtocolRequest { export interface GroupRequest extends ProtocolRequest {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
} }
export interface SyncGroupDataResponse extends ProtocolResponse { export interface GroupDataResponse extends ProtocolResponse {
// n. {동료그룹정보}... // n. {동료그룹정보}...
groupInfos: GroupInfo[]; groupInfos: GroupInfo[];
} }
export interface SyncGroupDataDetailResponse extends ProtocolResponse { export interface GroupDataDetailResponse extends ProtocolResponse {
// 그룹SEQ(n) // 그룹SEQ(n)
seq: number; seq: number;
// 그룹이름(s) // 그룹이름(s)
@ -40,13 +40,13 @@ export interface SyncGroupDataDetailResponse extends ProtocolResponse {
userSeqs: number[]; userSeqs: number[];
} }
export interface SyncGroupResponse extends ProtocolResponse { export interface GroupResponse extends ProtocolResponse {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
} }
export const encodeSyncGroup: ProtocolEncoder<SyncGroupRequest> = ( export const encodeGroup: ProtocolEncoder<GroupRequest> = (
req: SyncGroupRequest req: GroupRequest
) => { ) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
@ -54,15 +54,15 @@ export const encodeSyncGroup: ProtocolEncoder<SyncGroupRequest> = (
return bodyList; return bodyList;
}; };
export const decodeSyncGroup: ProtocolDecoder<SyncGroupResponse> = ( export const decodeGroup: ProtocolDecoder<GroupResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
syncDate: message.bodyList[0] syncDate: message.bodyList[0]
} as SyncGroupResponse; } as GroupResponse;
}; };
export const decodeSyncGroupData: ProtocolDecoder<SyncGroupDataResponse> = ( export const decodeGroupData: ProtocolDecoder<GroupDataResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const groupInfos: GroupInfo[] = []; const groupInfos: GroupInfo[] = [];
@ -78,12 +78,12 @@ export const decodeSyncGroupData: ProtocolDecoder<SyncGroupDataResponse> = (
return { return {
groupInfos groupInfos
} as SyncGroupDataResponse; } as GroupDataResponse;
}; };
export const decodeSyncGroupDataDetail: ProtocolDecoder< export const decodeGroupDataDetail: ProtocolDecoder<GroupDataDetailResponse> = (
SyncGroupDataDetailResponse message: ProtocolMessage
> = (message: ProtocolMessage) => { ) => {
let userSeqs: number[] = []; let userSeqs: number[] = [];
if (message.bodyList.length > 3) { if (message.bodyList.length > 3) {
userSeqs = message.bodyList.slice(3); userSeqs = message.bodyList.slice(3);
@ -97,5 +97,5 @@ export const decodeSyncGroupDataDetail: ProtocolDecoder<
isActive: message.bodyList[2] === 'Y' ? true : false, isActive: message.bodyList[2] === 'Y' ? true : false,
// 사용자SEQ(n)1 // 사용자SEQ(n)1
userSeqs userSeqs
} as SyncGroupDataDetailResponse; } as GroupDataDetailResponse;
}; };

View File

@ -18,40 +18,38 @@ import {
import { RoleCode } from '@ucap-webmessenger/protocol-authentication'; import { RoleCode } from '@ucap-webmessenger/protocol-authentication';
import { EventType } from '@ucap-webmessenger/protocol-event'; import { EventType } from '@ucap-webmessenger/protocol-event';
export interface SyncRoomRequest extends ProtocolRequest { export interface RoomRequest extends ProtocolRequest {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
// 언어코드 // 언어코드
localeCode: LocaleCode; localeCode: LocaleCode;
} }
export interface SyncRoomDataResponse extends ProtocolResponse { export interface RoomDataResponse extends ProtocolResponse {
// n. {대화방정보}... // n. {대화방정보}...
roomInfos: RoomInfo[]; roomInfos: RoomInfo[];
} }
export interface SyncRoomUserDataResponse extends ProtocolResponse { export interface RoomUserDataResponse extends ProtocolResponse {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보} // 1n. {참여자정보}
userInfos: UserInfoShort[]; userInfos: UserInfoShort[];
} }
export interface SyncRoomUserDataDetailResponse extends ProtocolResponse { export interface RoomUserDataDetailResponse extends ProtocolResponse {
// 0. 대화방SEQ(s) // 0. 대화방SEQ(s)
roomSeq: string; roomSeq: string;
// 1n. {참여자정보-D} // 1n. {참여자정보-D}
userInfos: UserInfo[]; userInfos: UserInfo[];
} }
export interface SyncRoomResponse extends ProtocolResponse { export interface RoomResponse extends ProtocolResponse {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42 // 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string; syncDate: string;
} }
export const encodeSyncRoom: ProtocolEncoder<SyncRoomRequest> = ( export const encodeRoom: ProtocolEncoder<RoomRequest> = (req: RoomRequest) => {
req: SyncRoomRequest
) => {
const bodyList: PacketBody[] = []; const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' }); bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' });
@ -59,15 +57,15 @@ export const encodeSyncRoom: ProtocolEncoder<SyncRoomRequest> = (
return bodyList; return bodyList;
}; };
export const decodeSyncRoom: ProtocolDecoder<SyncRoomResponse> = ( export const decodeRoom: ProtocolDecoder<RoomResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
return { return {
syncDate: message.bodyList[0] syncDate: message.bodyList[0]
} as SyncRoomResponse; } as RoomResponse;
}; };
export const decodeSyncRoomData: ProtocolDecoder<SyncRoomDataResponse> = ( export const decodeRoomData: ProtocolDecoder<RoomDataResponse> = (
message: ProtocolMessage message: ProtocolMessage
) => { ) => {
const roomInfos: RoomInfo[] = []; const roomInfos: RoomInfo[] = [];
@ -95,12 +93,12 @@ export const decodeSyncRoomData: ProtocolDecoder<SyncRoomDataResponse> = (
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
roomInfos roomInfos
} as SyncRoomDataResponse; } as RoomDataResponse;
}; };
export const decodeSyncRoomUserData: ProtocolDecoder< export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = (
SyncRoomUserDataResponse 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);
@ -125,11 +123,11 @@ export const decodeSyncRoomUserData: ProtocolDecoder<
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as SyncRoomUserDataResponse; } as RoomUserDataResponse;
}; };
export const decodeSyncRoomUserDataDetail: ProtocolDecoder< export const decodeRoomUserDataDetail: ProtocolDecoder<
SyncRoomUserDataDetailResponse RoomUserDataDetailResponse
> = (message: ProtocolMessage) => { > = (message: ProtocolMessage) => {
const userInfos: UserInfo[] = []; const userInfos: UserInfo[] = [];
message.bodyList.slice(1).forEach(userInfo => { message.bodyList.slice(1).forEach(userInfo => {
@ -171,5 +169,5 @@ export const decodeSyncRoomUserDataDetail: ProtocolDecoder<
return { return {
roomSeq: message.bodyList[0], roomSeq: message.bodyList[0],
userInfos userInfos
} as SyncRoomUserDataDetailResponse; } as RoomUserDataDetailResponse;
}; };

View File

@ -5,13 +5,13 @@ import { map, take, takeWhile } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import { import {
SyncBuddyRequest, BuddyRequest,
SyncBuddyResponse, BuddyResponse,
SyncBuddyDataResponse, BuddyDataResponse,
encodeSyncBuddy, encodeBuddy,
decodeSyncBuddyData, decodeBuddyData,
decodeSyncBuddy, decodeBuddy,
decodeSyncBuddyDataDetail decodeBuddyDataDetail
} from '../models/buddy'; } from '../models/buddy';
import { import {
SVC_TYPE_SYNC_BUDDY, SVC_TYPE_SYNC_BUDDY,
@ -41,26 +41,26 @@ import {
SSVC_TYPE_SYNC_ROOM2_USER2 SSVC_TYPE_SYNC_ROOM2_USER2
} from '../types/service'; } from '../types/service';
import { import {
SyncGroupRequest, GroupRequest,
SyncGroupResponse, GroupResponse,
SyncGroupDataResponse, GroupDataResponse,
encodeSyncGroup, encodeGroup,
decodeSyncGroupDataDetail, decodeGroupDataDetail,
decodeSyncGroup, decodeGroup,
decodeSyncGroupData, decodeGroupData,
SyncGroupDataDetailResponse GroupDataDetailResponse
} from '../models/group'; } from '../models/group';
import { import {
SyncRoomRequest, RoomRequest,
SyncRoomResponse, RoomResponse,
encodeSyncRoom, encodeRoom,
decodeSyncRoom, decodeRoom,
SyncRoomUserDataResponse, RoomUserDataResponse,
SyncRoomUserDataDetailResponse, RoomUserDataDetailResponse,
SyncRoomDataResponse, RoomDataResponse,
decodeSyncRoomData, decodeRoomData,
decodeSyncRoomUserData, decodeRoomUserData,
decodeSyncRoomUserDataDetail decodeRoomUserDataDetail
} from '../models/room'; } from '../models/room';
@Injectable({ @Injectable({
@ -69,142 +69,122 @@ import {
export class SyncProtocolService { export class SyncProtocolService {
constructor(private protocolService: ProtocolService) {} constructor(private protocolService: ProtocolService) {}
public syncBuddy( public buddy(
req: SyncBuddyRequest req: BuddyRequest
): Observable<SyncBuddyResponse | SyncBuddyDataResponse> { ): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY_REQ, ...encodeBuddy(req))
SVC_TYPE_SYNC_BUDDY,
SSVC_TYPE_SYNC_BUDDY_REQ,
...encodeSyncBuddy(req)
)
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) {
return decodeSyncBuddyData(res); return decodeBuddyData(res);
} }
return decodeSyncBuddy(res); return decodeBuddy(res);
}) })
); );
} }
public syncBuddy2( public buddy2(
req: SyncBuddyRequest req: BuddyRequest
): Observable<SyncBuddyResponse | SyncBuddyDataResponse> { ): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY2_REQ, ...encodeBuddy(req))
SVC_TYPE_SYNC_BUDDY,
SSVC_TYPE_SYNC_BUDDY2_REQ,
...encodeSyncBuddy(req)
)
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY2_RES !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_BUDDY2_RES !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) {
return decodeSyncBuddyDataDetail(res); return decodeBuddyDataDetail(res);
} }
return decodeSyncBuddy(res); return decodeBuddy(res);
}) })
); );
} }
public syncGroup( public syncGroup(
req: SyncGroupRequest req: GroupRequest
): Observable<SyncGroupResponse | SyncGroupDataResponse> { ): Observable<GroupResponse | GroupDataResponse> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ, ...encodeGroup(req))
SVC_TYPE_SYNC_GROUP,
SSVC_TYPE_SYNC_GROUP_REQ,
...encodeSyncGroup(req)
)
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) {
return decodeSyncGroupData(res); return decodeGroupData(res);
} }
return decodeSyncGroup(res); return decodeGroup(res);
}) })
); );
} }
public syncGroup2( public syncGroup2(
req: SyncGroupRequest req: GroupRequest
): Observable<SyncGroupResponse | SyncGroupDataDetailResponse> { ): Observable<GroupResponse | GroupDataDetailResponse> {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ2, ...encodeGroup(req))
SVC_TYPE_SYNC_GROUP,
SSVC_TYPE_SYNC_GROUP_REQ2,
...encodeSyncGroup(req)
)
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES2 !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES2 !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) { if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) {
return decodeSyncGroupDataDetail(res); return decodeGroupDataDetail(res);
} }
return decodeSyncGroup(res); return decodeGroup(res);
}) })
); );
} }
public syncRoom( public syncRoom(
req: SyncRoomRequest req: RoomRequest
): Observable< ): Observable<
| SyncRoomResponse | RoomResponse
| SyncRoomDataResponse | RoomDataResponse
| SyncRoomUserDataResponse | RoomUserDataResponse
| SyncRoomUserDataDetailResponse | RoomUserDataDetailResponse
> { > {
return this.protocolService return this.protocolService
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeSyncRoom(req)) .call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM_REQ, ...encodeRoom(req))
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) {
return decodeSyncRoomData(res); return decodeRoomData(res);
} else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) {
return decodeSyncRoomUserData(res); return decodeRoomUserData(res);
} else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) {
return decodeSyncRoomUserDataDetail(res); return decodeRoomUserDataDetail(res);
} }
return decodeSyncRoom(res); return decodeRoom(res);
}) })
); );
} }
public syncRoom2( public syncRoom2(
req: SyncRoomRequest req: RoomRequest
): Observable< ): Observable<
| SyncRoomResponse | RoomResponse
| SyncRoomDataResponse | RoomDataResponse
| SyncRoomUserDataResponse | RoomUserDataResponse
| SyncRoomUserDataDetailResponse | RoomUserDataDetailResponse
> { > {
return this.protocolService return this.protocolService
.call( .call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM2_REQ, ...encodeRoom(req))
SVC_TYPE_SYNC_ROOM,
SSVC_TYPE_SYNC_ROOM2_REQ,
...encodeSyncRoom(req)
)
.pipe( .pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType), takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType),
map(res => { map(res => {
if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) { if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) {
return decodeSyncRoomData(res); return decodeRoomData(res);
} else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) {
return decodeSyncRoomUserData(res); return decodeRoomUserData(res);
} else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) { } else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) {
return decodeSyncRoomUserDataDetail(res); return decodeRoomUserDataDetail(res);
} }
return decodeSyncRoom(res); return decodeRoom(res);
}) })
); );
} }