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

View File

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

View File

@ -18,40 +18,38 @@ import {
import { RoleCode } from '@ucap-webmessenger/protocol-authentication';
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
syncDate: string;
// 언어코드
localeCode: LocaleCode;
}
export interface SyncRoomDataResponse extends ProtocolResponse {
export interface RoomDataResponse extends ProtocolResponse {
// n. {대화방정보}...
roomInfos: RoomInfo[];
}
export interface SyncRoomUserDataResponse extends ProtocolResponse {
export interface RoomUserDataResponse extends ProtocolResponse {
// 0. 대화방SEQ(s)
roomSeq: string;
// 1n. {참여자정보}
userInfos: UserInfoShort[];
}
export interface SyncRoomUserDataDetailResponse extends ProtocolResponse {
export interface RoomUserDataDetailResponse extends ProtocolResponse {
// 0. 대화방SEQ(s)
roomSeq: string;
// 1n. {참여자정보-D}
userInfos: UserInfo[];
}
export interface SyncRoomResponse extends ProtocolResponse {
export interface RoomResponse extends ProtocolResponse {
// 0. 동료 씽크일시(s) cf)2019-09-24 16:51:42
syncDate: string;
}
export const encodeSyncRoom: ProtocolEncoder<SyncRoomRequest> = (
req: SyncRoomRequest
) => {
export const encodeRoom: ProtocolEncoder<RoomRequest> = (req: RoomRequest) => {
const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' });
@ -59,15 +57,15 @@ export const encodeSyncRoom: ProtocolEncoder<SyncRoomRequest> = (
return bodyList;
};
export const decodeSyncRoom: ProtocolDecoder<SyncRoomResponse> = (
export const decodeRoom: ProtocolDecoder<RoomResponse> = (
message: ProtocolMessage
) => {
return {
syncDate: message.bodyList[0]
} as SyncRoomResponse;
} as RoomResponse;
};
export const decodeSyncRoomData: ProtocolDecoder<SyncRoomDataResponse> = (
export const decodeRoomData: ProtocolDecoder<RoomDataResponse> = (
message: ProtocolMessage
) => {
const roomInfos: RoomInfo[] = [];
@ -95,12 +93,12 @@ export const decodeSyncRoomData: ProtocolDecoder<SyncRoomDataResponse> = (
return {
roomSeq: message.bodyList[0],
roomInfos
} as SyncRoomDataResponse;
} as RoomDataResponse;
};
export const decodeSyncRoomUserData: ProtocolDecoder<
SyncRoomUserDataResponse
> = (message: ProtocolMessage) => {
export const decodeRoomUserData: ProtocolDecoder<RoomUserDataResponse> = (
message: ProtocolMessage
) => {
const userInfos: UserInfoShort[] = [];
message.bodyList.slice(1).forEach(userInfo => {
const info = userInfo.split(BodyStringDivider);
@ -125,11 +123,11 @@ export const decodeSyncRoomUserData: ProtocolDecoder<
return {
roomSeq: message.bodyList[0],
userInfos
} as SyncRoomUserDataResponse;
} as RoomUserDataResponse;
};
export const decodeSyncRoomUserDataDetail: ProtocolDecoder<
SyncRoomUserDataDetailResponse
export const decodeRoomUserDataDetail: ProtocolDecoder<
RoomUserDataDetailResponse
> = (message: ProtocolMessage) => {
const userInfos: UserInfo[] = [];
message.bodyList.slice(1).forEach(userInfo => {
@ -171,5 +169,5 @@ export const decodeSyncRoomUserDataDetail: ProtocolDecoder<
return {
roomSeq: message.bodyList[0],
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 {
SyncBuddyRequest,
SyncBuddyResponse,
SyncBuddyDataResponse,
encodeSyncBuddy,
decodeSyncBuddyData,
decodeSyncBuddy,
decodeSyncBuddyDataDetail
BuddyRequest,
BuddyResponse,
BuddyDataResponse,
encodeBuddy,
decodeBuddyData,
decodeBuddy,
decodeBuddyDataDetail
} from '../models/buddy';
import {
SVC_TYPE_SYNC_BUDDY,
@ -41,26 +41,26 @@ import {
SSVC_TYPE_SYNC_ROOM2_USER2
} from '../types/service';
import {
SyncGroupRequest,
SyncGroupResponse,
SyncGroupDataResponse,
encodeSyncGroup,
decodeSyncGroupDataDetail,
decodeSyncGroup,
decodeSyncGroupData,
SyncGroupDataDetailResponse
GroupRequest,
GroupResponse,
GroupDataResponse,
encodeGroup,
decodeGroupDataDetail,
decodeGroup,
decodeGroupData,
GroupDataDetailResponse
} from '../models/group';
import {
SyncRoomRequest,
SyncRoomResponse,
encodeSyncRoom,
decodeSyncRoom,
SyncRoomUserDataResponse,
SyncRoomUserDataDetailResponse,
SyncRoomDataResponse,
decodeSyncRoomData,
decodeSyncRoomUserData,
decodeSyncRoomUserDataDetail
RoomRequest,
RoomResponse,
encodeRoom,
decodeRoom,
RoomUserDataResponse,
RoomUserDataDetailResponse,
RoomDataResponse,
decodeRoomData,
decodeRoomUserData,
decodeRoomUserDataDetail
} from '../models/room';
@Injectable({
@ -69,142 +69,122 @@ import {
export class SyncProtocolService {
constructor(private protocolService: ProtocolService) {}
public syncBuddy(
req: SyncBuddyRequest
): Observable<SyncBuddyResponse | SyncBuddyDataResponse> {
public buddy(
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService
.call(
SVC_TYPE_SYNC_BUDDY,
SSVC_TYPE_SYNC_BUDDY_REQ,
...encodeSyncBuddy(req)
)
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY_REQ, ...encodeBuddy(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY_RES !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_BUDDY_DATA === res.subServiceType) {
return decodeSyncBuddyData(res);
return decodeBuddyData(res);
}
return decodeSyncBuddy(res);
return decodeBuddy(res);
})
);
}
public syncBuddy2(
req: SyncBuddyRequest
): Observable<SyncBuddyResponse | SyncBuddyDataResponse> {
public buddy2(
req: BuddyRequest
): Observable<BuddyResponse | BuddyDataResponse> {
return this.protocolService
.call(
SVC_TYPE_SYNC_BUDDY,
SSVC_TYPE_SYNC_BUDDY2_REQ,
...encodeSyncBuddy(req)
)
.call(SVC_TYPE_SYNC_BUDDY, SSVC_TYPE_SYNC_BUDDY2_REQ, ...encodeBuddy(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_BUDDY2_RES !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_BUDDY2_DATA === res.subServiceType) {
return decodeSyncBuddyDataDetail(res);
return decodeBuddyDataDetail(res);
}
return decodeSyncBuddy(res);
return decodeBuddy(res);
})
);
}
public syncGroup(
req: SyncGroupRequest
): Observable<SyncGroupResponse | SyncGroupDataResponse> {
req: GroupRequest
): Observable<GroupResponse | GroupDataResponse> {
return this.protocolService
.call(
SVC_TYPE_SYNC_GROUP,
SSVC_TYPE_SYNC_GROUP_REQ,
...encodeSyncGroup(req)
)
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ, ...encodeGroup(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA === res.subServiceType) {
return decodeSyncGroupData(res);
return decodeGroupData(res);
}
return decodeSyncGroup(res);
return decodeGroup(res);
})
);
}
public syncGroup2(
req: SyncGroupRequest
): Observable<SyncGroupResponse | SyncGroupDataDetailResponse> {
req: GroupRequest
): Observable<GroupResponse | GroupDataDetailResponse> {
return this.protocolService
.call(
SVC_TYPE_SYNC_GROUP,
SSVC_TYPE_SYNC_GROUP_REQ2,
...encodeSyncGroup(req)
)
.call(SVC_TYPE_SYNC_GROUP, SSVC_TYPE_SYNC_GROUP_REQ2, ...encodeGroup(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_GROUP_RES2 !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_GROUP_DATA2 === res.subServiceType) {
return decodeSyncGroupDataDetail(res);
return decodeGroupDataDetail(res);
}
return decodeSyncGroup(res);
return decodeGroup(res);
})
);
}
public syncRoom(
req: SyncRoomRequest
req: RoomRequest
): Observable<
| SyncRoomResponse
| SyncRoomDataResponse
| SyncRoomUserDataResponse
| SyncRoomUserDataDetailResponse
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
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(
takeWhile(res => SSVC_TYPE_SYNC_ROOM_RES !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_ROOM_DATA === res.subServiceType) {
return decodeSyncRoomData(res);
return decodeRoomData(res);
} else if (SSVC_TYPE_SYNC_ROOM_USER === res.subServiceType) {
return decodeSyncRoomUserData(res);
return decodeRoomUserData(res);
} else if (SSVC_TYPE_SYNC_ROOM_USER2 === res.subServiceType) {
return decodeSyncRoomUserDataDetail(res);
return decodeRoomUserDataDetail(res);
}
return decodeSyncRoom(res);
return decodeRoom(res);
})
);
}
public syncRoom2(
req: SyncRoomRequest
req: RoomRequest
): Observable<
| SyncRoomResponse
| SyncRoomDataResponse
| SyncRoomUserDataResponse
| SyncRoomUserDataDetailResponse
| RoomResponse
| RoomDataResponse
| RoomUserDataResponse
| RoomUserDataDetailResponse
> {
return this.protocolService
.call(
SVC_TYPE_SYNC_ROOM,
SSVC_TYPE_SYNC_ROOM2_REQ,
...encodeSyncRoom(req)
)
.call(SVC_TYPE_SYNC_ROOM, SSVC_TYPE_SYNC_ROOM2_REQ, ...encodeRoom(req))
.pipe(
takeWhile(res => SSVC_TYPE_SYNC_ROOM2_RES !== res.subServiceType),
map(res => {
if (SSVC_TYPE_SYNC_ROOM2_DATA === res.subServiceType) {
return decodeSyncRoomData(res);
return decodeRoomData(res);
} else if (SSVC_TYPE_SYNC_ROOM2_USER === res.subServiceType) {
return decodeSyncRoomUserData(res);
return decodeRoomUserData(res);
} else if (SSVC_TYPE_SYNC_ROOM2_USER2 === res.subServiceType) {
return decodeSyncRoomUserDataDetail(res);
return decodeRoomUserDataDetail(res);
}
return decodeSyncRoom(res);
return decodeRoom(res);
})
);
}