diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts index caeab8dd..844e5ac3 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/buddy.ts @@ -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 = ( - req: SyncBuddyRequest +export const encodeBuddy: ProtocolEncoder = ( + req: BuddyRequest ) => { const bodyList: PacketBody[] = []; @@ -48,15 +48,15 @@ export const encodeSyncBuddy: ProtocolEncoder = ( return bodyList; }; -export const decodeSyncBuddy: ProtocolDecoder = ( +export const decodeBuddy: ProtocolDecoder = ( message: ProtocolMessage ) => { return { syncDate: message.bodyList[0] - } as SyncBuddyResponse; + } as BuddyResponse; }; -export const decodeSyncBuddyData: ProtocolDecoder = ( +export const decodeBuddyData: ProtocolDecoder = ( message: ProtocolMessage ) => { const buddyInfos: BuddyInfo[] = []; @@ -70,12 +70,12 @@ export const decodeSyncBuddyData: ProtocolDecoder = ( }); return { buddyInfos - } as SyncBuddyDataResponse; + } as BuddyDataResponse; }; -export const decodeSyncBuddyDataDetail: ProtocolDecoder< - SyncBuddyDataDetailResponse -> = (message: ProtocolMessage) => { +export const decodeBuddyDataDetail: ProtocolDecoder = ( + 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; }; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts index ab767624..8bcdfbda 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/group.ts @@ -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 = ( - req: SyncGroupRequest +export const encodeGroup: ProtocolEncoder = ( + req: GroupRequest ) => { const bodyList: PacketBody[] = []; @@ -54,15 +54,15 @@ export const encodeSyncGroup: ProtocolEncoder = ( return bodyList; }; -export const decodeSyncGroup: ProtocolDecoder = ( +export const decodeGroup: ProtocolDecoder = ( message: ProtocolMessage ) => { return { syncDate: message.bodyList[0] - } as SyncGroupResponse; + } as GroupResponse; }; -export const decodeSyncGroupData: ProtocolDecoder = ( +export const decodeGroupData: ProtocolDecoder = ( message: ProtocolMessage ) => { const groupInfos: GroupInfo[] = []; @@ -78,12 +78,12 @@ export const decodeSyncGroupData: ProtocolDecoder = ( return { groupInfos - } as SyncGroupDataResponse; + } as GroupDataResponse; }; -export const decodeSyncGroupDataDetail: ProtocolDecoder< - SyncGroupDataDetailResponse -> = (message: ProtocolMessage) => { +export const decodeGroupDataDetail: ProtocolDecoder = ( + 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; }; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts index e5917126..35b1d806 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/models/room.ts @@ -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 = ( - req: SyncRoomRequest -) => { +export const encodeRoom: ProtocolEncoder = (req: RoomRequest) => { const bodyList: PacketBody[] = []; bodyList.push({ type: PacketBodyValue.String, value: req.syncDate || '' }); @@ -59,15 +57,15 @@ export const encodeSyncRoom: ProtocolEncoder = ( return bodyList; }; -export const decodeSyncRoom: ProtocolDecoder = ( +export const decodeRoom: ProtocolDecoder = ( message: ProtocolMessage ) => { return { syncDate: message.bodyList[0] - } as SyncRoomResponse; + } as RoomResponse; }; -export const decodeSyncRoomData: ProtocolDecoder = ( +export const decodeRoomData: ProtocolDecoder = ( message: ProtocolMessage ) => { const roomInfos: RoomInfo[] = []; @@ -95,12 +93,12 @@ export const decodeSyncRoomData: ProtocolDecoder = ( return { roomSeq: message.bodyList[0], roomInfos - } as SyncRoomDataResponse; + } as RoomDataResponse; }; -export const decodeSyncRoomUserData: ProtocolDecoder< - SyncRoomUserDataResponse -> = (message: ProtocolMessage) => { +export const decodeRoomUserData: ProtocolDecoder = ( + 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; }; diff --git a/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts b/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts index ff96c854..c4979736 100644 --- a/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-sync/src/lib/services/sync-protocol.service.ts @@ -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 { + public buddy( + req: BuddyRequest + ): Observable { 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 { + public buddy2( + req: BuddyRequest + ): Observable { 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 { + req: GroupRequest + ): Observable { 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 { + req: GroupRequest + ): Observable { 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); }) ); }