다른디바이스와의 Sync 처리. ::: 동료 / 그룹
This commit is contained in:
parent
93eb386825
commit
fb94b5480a
|
@ -1,8 +1,9 @@
|
||||||
|
import { delGroupSuccess, buddy2 } from './../store/messenger/sync/actions';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap, withLatestFrom } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SSVC_TYPE_LOGOUT_RES,
|
SSVC_TYPE_LOGOUT_RES,
|
||||||
|
@ -35,7 +36,7 @@ import {
|
||||||
SSVC_TYPE_ROOM_EXIT_FORCING_NOTI,
|
SSVC_TYPE_ROOM_EXIT_FORCING_NOTI,
|
||||||
SSVC_TYPE_ROOM_FONT_UPD_NOTI,
|
SSVC_TYPE_ROOM_FONT_UPD_NOTI,
|
||||||
InviteNotification,
|
InviteNotification,
|
||||||
UpdateNotification,
|
UpdateNotification as RoomUpdateNotification,
|
||||||
SSVC_TYPE_ROOM_UPD_RES
|
SSVC_TYPE_ROOM_UPD_RES
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import {
|
import {
|
||||||
|
@ -53,10 +54,29 @@ import {
|
||||||
ExitForcingNotification,
|
ExitForcingNotification,
|
||||||
UpdateFontNotification
|
UpdateFontNotification
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
|
import {
|
||||||
|
GroupProtocolService,
|
||||||
|
SSVC_TYPE_GROUP_UPD_RES2,
|
||||||
|
UpdateNotification as GroupUpdateNotification,
|
||||||
|
SSVC_TYPE_GROUP_ADD_RES,
|
||||||
|
AddNotification as GroupAddNotification,
|
||||||
|
SSVC_TYPE_GROUP_DEL_RES,
|
||||||
|
DelNotification as GroupDelNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-group';
|
||||||
|
import {
|
||||||
|
BuddyProtocolService,
|
||||||
|
SSVC_TYPE_BUDDY_UPD_RES,
|
||||||
|
UpdateNotification as BuddyUpdateNotification,
|
||||||
|
SSVC_TYPE_BUDDY_ADD_RES,
|
||||||
|
AddNotification as BuddyAddNotification,
|
||||||
|
SSVC_TYPE_BUDDY_DEL_RES,
|
||||||
|
DelNotification as BuddyDelNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-buddy';
|
||||||
|
|
||||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||||
import * as InfoStore from '@app/store/account/info';
|
import * as InfoStore from '@app/store/account/info';
|
||||||
import * as EventStore from '@app/store/messenger/event';
|
import * as EventStore from '@app/store/messenger/event';
|
||||||
|
import * as SyncStore from '@app/store/messenger/sync';
|
||||||
import * as RoomStore from '@app/store/messenger/room';
|
import * as RoomStore from '@app/store/messenger/room';
|
||||||
import * as StatusStore from '@app/store/messenger/status';
|
import * as StatusStore from '@app/store/messenger/status';
|
||||||
|
|
||||||
|
@ -67,6 +87,8 @@ export class AppNotificationService {
|
||||||
private eventProtocolService: EventProtocolService,
|
private eventProtocolService: EventProtocolService,
|
||||||
private infoProtocolService: InfoProtocolService,
|
private infoProtocolService: InfoProtocolService,
|
||||||
private roomProtocolService: RoomProtocolService,
|
private roomProtocolService: RoomProtocolService,
|
||||||
|
private groupProtocolService: GroupProtocolService,
|
||||||
|
private buddyProtocolService: BuddyProtocolService,
|
||||||
private statusProtocolService: StatusProtocolService,
|
private statusProtocolService: StatusProtocolService,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
private logger: NGXLogger
|
private logger: NGXLogger
|
||||||
|
@ -197,15 +219,115 @@ export class AppNotificationService {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
this.groupProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select(
|
||||||
|
(state: any) => state.messenger.sync.group2.syncDate as string
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
tap(([notiOrRes, syncDate]) => {
|
||||||
|
switch (notiOrRes.SSVC_TYPE) {
|
||||||
|
case SSVC_TYPE_GROUP_UPD_RES2:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as GroupUpdateNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::GroupUpdateNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(
|
||||||
|
SyncStore.group2({
|
||||||
|
syncDate
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_GROUP_ADD_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as GroupAddNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::GroupAddNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(SyncStore.createGroupSuccess(noti));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_GROUP_DEL_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as GroupDelNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::GroupDelNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(SyncStore.delGroupSuccess(noti));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
this.buddyProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select(
|
||||||
|
(state: any) => state.messenger.sync.buddy2.syncDate as string
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
tap(([notiOrRes, syncDate]) => {
|
||||||
|
switch (notiOrRes.SSVC_TYPE) {
|
||||||
|
case SSVC_TYPE_BUDDY_UPD_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as BuddyUpdateNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::BuddyUpdateNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(SyncStore.updateBuddySuccess(noti));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_BUDDY_ADD_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as BuddyAddNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::BuddyAddNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(SyncStore.buddy2({ syncDate }));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_BUDDY_DEL_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as BuddyDelNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::groupProtocolService::BuddyDelNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
this.store.dispatch(SyncStore.delBuddySuccess(noti));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
this.roomProtocolService.notification$
|
this.roomProtocolService.notification$
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(notiOrRes => {
|
tap(notiOrRes => {
|
||||||
switch (notiOrRes.SSVC_TYPE) {
|
switch (notiOrRes.SSVC_TYPE) {
|
||||||
case SSVC_TYPE_ROOM_UPD_RES:
|
case SSVC_TYPE_ROOM_UPD_RES:
|
||||||
{
|
{
|
||||||
const noti = notiOrRes as UpdateNotification;
|
const noti = notiOrRes as RoomUpdateNotification;
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
'Notification::roomProtocolService::UpdateNotification',
|
'Notification::roomProtocolService::RoomUpdateNotification',
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
|
|
|
@ -571,73 +571,68 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
delGroup$ = createEffect(
|
delGroup$ = createEffect(() =>
|
||||||
() => {
|
this.actions$.pipe(
|
||||||
return this.actions$.pipe(
|
ofType(delGroup),
|
||||||
ofType(delGroup),
|
withLatestFrom(
|
||||||
withLatestFrom(
|
this.store.pipe(
|
||||||
this.store.pipe(
|
select(
|
||||||
select(
|
(state: any) =>
|
||||||
(state: any) =>
|
state.messenger.sync.group2.entities as Dictionary<
|
||||||
state.messenger.sync.group2.entities as Dictionary<
|
GroupDetailData
|
||||||
GroupDetailData
|
>
|
||||||
>
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
map(([action, groupList]) => {
|
),
|
||||||
// Del Buddy
|
exhaustMap(([action, groupList]) => {
|
||||||
const trgtBuddys = action.group.userSeqs;
|
// Del Buddy
|
||||||
// tslint:disable-next-line: no-shadowed-variable
|
const trgtBuddys = action.group.userSeqs;
|
||||||
const delBuddyList = trgtBuddys.filter(delBuddy => {
|
// tslint:disable-next-line: no-shadowed-variable
|
||||||
let exist = false;
|
const delBuddyList = trgtBuddys.filter(delBuddy => {
|
||||||
// tslint:disable-next-line: forin
|
let exist = false;
|
||||||
for (const key in groupList) {
|
// tslint:disable-next-line: forin
|
||||||
const group: GroupDetailData = groupList[key];
|
for (const key in groupList) {
|
||||||
if (
|
const group: GroupDetailData = groupList[key];
|
||||||
group.seq !== action.group.seq &&
|
if (
|
||||||
group.userSeqs.filter(v => v === delBuddy).length > 0
|
group.seq !== action.group.seq &&
|
||||||
) {
|
group.userSeqs.filter(v => v === delBuddy).length > 0
|
||||||
exist = true;
|
) {
|
||||||
break;
|
exist = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
return !exist;
|
}
|
||||||
|
return !exist;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (delBuddyList.length > 0) {
|
||||||
|
this.logger.debug('Del Buddy', delBuddyList);
|
||||||
|
// 즐겨찾기 해제.
|
||||||
|
delBuddyList.forEach(buddySeq => {
|
||||||
|
this.buddyProtocolService
|
||||||
|
.update({
|
||||||
|
seq: buddySeq,
|
||||||
|
isFavorit: false
|
||||||
|
})
|
||||||
|
.pipe(catchError(error => of(delBuddyFailure({ error }))));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (delBuddyList.length > 0) {
|
// 동료 삭제
|
||||||
this.logger.debug('Del Buddy', delBuddyList);
|
this.store.dispatch(delBuddy({ userSeqs: delBuddyList }));
|
||||||
// 즐겨찾기 해제.
|
}
|
||||||
delBuddyList.forEach(buddySeq => {
|
|
||||||
this.buddyProtocolService
|
|
||||||
.update({
|
|
||||||
seq: buddySeq,
|
|
||||||
isFavorit: false
|
|
||||||
})
|
|
||||||
.pipe(catchError(error => of(delBuddyFailure({ error }))));
|
|
||||||
});
|
|
||||||
|
|
||||||
// 동료 삭제
|
return this.groupProtocolService
|
||||||
this.store.dispatch(delBuddy({ userSeqs: delBuddyList }));
|
.del({
|
||||||
}
|
groupSeq: action.group.seq
|
||||||
|
})
|
||||||
return action.group;
|
.pipe(
|
||||||
}),
|
map((res: GroupDelResponse) => {
|
||||||
tap(group => {
|
// this.store.dispatch(delGroupSuccess(res));
|
||||||
this.groupProtocolService
|
return delGroupSuccess(res);
|
||||||
.del({
|
}),
|
||||||
groupSeq: group.seq
|
catchError(error => of(delGroupFailure({ error })))
|
||||||
})
|
);
|
||||||
.pipe(
|
})
|
||||||
map((res: GroupDelResponse) => {
|
)
|
||||||
return delGroupSuccess(res);
|
|
||||||
}),
|
|
||||||
catchError(error => of(delGroupFailure({ error })))
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
|
||||||
{ dispatch: false }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
addBuddy$ = createEffect(() =>
|
addBuddy$ = createEffect(() =>
|
||||||
|
@ -674,11 +669,6 @@ export class Effects {
|
||||||
map((res: BuddyDelResponse) => {
|
map((res: BuddyDelResponse) => {
|
||||||
return delBuddySuccess(res);
|
return delBuddySuccess(res);
|
||||||
}),
|
}),
|
||||||
// map((res: BuddyDelResponse) => {
|
|
||||||
// return buddy2({
|
|
||||||
// syncDate
|
|
||||||
// });
|
|
||||||
// }),
|
|
||||||
catchError(error => of(delBuddyFailure({ error })))
|
catchError(error => of(delBuddyFailure({ error })))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,16 +7,22 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface AddRequest extends ProtocolRequest {
|
export interface AddRequest extends ProtocolRequest {
|
||||||
// 0n. 사용자SEQ(n)...
|
/** 0n. 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddResponse extends ProtocolResponse {
|
export interface AddResponse extends ProtocolResponse {
|
||||||
// 0n. 사용자SEQ(n)...
|
/** 0n. 사용자SEQ(n)... */
|
||||||
|
userSeqs: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AddNotification extends ProtocolNotification {
|
||||||
|
/** 0n. 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,3 +44,12 @@ export const decodeAdd: ProtocolDecoder<AddResponse> = (
|
||||||
userSeqs: userSeqArray
|
userSeqs: userSeqArray
|
||||||
} as AddResponse);
|
} as AddResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeAddNotification: ProtocolDecoder<AddNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
const userSeqArray: number[] = [...message.bodyList];
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
userSeqs: userSeqArray
|
||||||
|
} as AddNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -7,16 +7,22 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface DelRequest extends ProtocolRequest {
|
export interface DelRequest extends ProtocolRequest {
|
||||||
// 0n. 사용자SEQ(n)...
|
/** 0n. 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DelResponse extends ProtocolResponse {
|
export interface DelResponse extends ProtocolResponse {
|
||||||
// 0n. 사용자SEQ(n)...
|
/** 0n. 사용자SEQ(n)... */
|
||||||
|
userSeqs: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DelNotification extends ProtocolNotification {
|
||||||
|
/** 0n. 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,3 +44,12 @@ export const decodeDel: ProtocolDecoder<DelResponse> = (
|
||||||
userSeqs: userSeqArray
|
userSeqs: userSeqArray
|
||||||
} as DelResponse);
|
} as DelResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeDelNotification: ProtocolDecoder<DelNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
const userSeqArray: number[] = [...message.bodyList];
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
userSeqs: userSeqArray
|
||||||
|
} as DelNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -7,7 +7,8 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface UpdateRequest extends ProtocolRequest {
|
export interface UpdateRequest extends ProtocolRequest {
|
||||||
|
@ -24,6 +25,13 @@ export interface UpdateResponse extends ProtocolResponse {
|
||||||
isFavorit: boolean;
|
isFavorit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UpdateNotification extends ProtocolNotification {
|
||||||
|
// 0. 사용자SEQ(n)
|
||||||
|
seq: number;
|
||||||
|
// 1. 즐겨찾기여부(y)
|
||||||
|
isFavorit: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
|
export const encodeUpdate: ProtocolEncoder<UpdateRequest> = (
|
||||||
req: UpdateRequest
|
req: UpdateRequest
|
||||||
) => {
|
) => {
|
||||||
|
@ -46,3 +54,12 @@ export const decodeUpdate: ProtocolDecoder<UpdateResponse> = (
|
||||||
isFavorit: message.bodyList[1] === 'Y' ? true : false
|
isFavorit: message.bodyList[1] === 'Y' ? true : false
|
||||||
} as UpdateResponse);
|
} as UpdateResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeUpdateNotification: ProtocolDecoder<UpdateNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
seq: message.bodyList[0],
|
||||||
|
isFavorit: message.bodyList[1] === 'Y' ? true : false
|
||||||
|
} as UpdateNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { map, take } from 'rxjs/operators';
|
import { map, take, share, filter, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
|
@ -9,33 +9,80 @@ import {
|
||||||
SVC_TYPE_BUDDY,
|
SVC_TYPE_BUDDY,
|
||||||
SSVC_TYPE_BUDDY_ADD_REQ,
|
SSVC_TYPE_BUDDY_ADD_REQ,
|
||||||
SSVC_TYPE_BUDDY_DEL_REQ,
|
SSVC_TYPE_BUDDY_DEL_REQ,
|
||||||
SSVC_TYPE_BUDDY_UPD_REQ
|
SSVC_TYPE_BUDDY_UPD_REQ,
|
||||||
|
SSVC_TYPE_BUDDY_UPD_RES,
|
||||||
|
SSVC_TYPE_BUDDY_ADD_RES,
|
||||||
|
SSVC_TYPE_BUDDY_DEL_RES
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AddRequest,
|
AddRequest,
|
||||||
encodeAdd,
|
encodeAdd,
|
||||||
decodeAdd,
|
decodeAdd,
|
||||||
AddResponse
|
AddResponse,
|
||||||
|
decodeAddNotification,
|
||||||
|
AddNotification
|
||||||
} from '../protocols/add';
|
} from '../protocols/add';
|
||||||
import {
|
import {
|
||||||
DelRequest,
|
DelRequest,
|
||||||
encodeDel,
|
encodeDel,
|
||||||
decodeDel,
|
decodeDel,
|
||||||
DelResponse
|
DelResponse,
|
||||||
|
decodeDelNotification,
|
||||||
|
DelNotification
|
||||||
} from '../protocols/del';
|
} from '../protocols/del';
|
||||||
import {
|
import {
|
||||||
UpdateRequest,
|
UpdateRequest,
|
||||||
decodeUpdate,
|
decodeUpdate,
|
||||||
encodeUpdate,
|
encodeUpdate,
|
||||||
UpdateResponse
|
UpdateResponse,
|
||||||
|
UpdateNotification,
|
||||||
|
decodeUpdateNotification
|
||||||
} from '../protocols/update';
|
} from '../protocols/update';
|
||||||
|
|
||||||
|
type Notifications = UpdateNotification | AddNotification | DelNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class BuddyProtocolService {
|
export class BuddyProtocolService {
|
||||||
constructor(private protocolService: ProtocolService) {}
|
private notificationSubject: Subject<Notifications>;
|
||||||
|
public notification$: Observable<Notifications>;
|
||||||
|
|
||||||
|
constructor(private protocolService: ProtocolService) {
|
||||||
|
this.notificationSubject = new Subject();
|
||||||
|
this.notification$ = this.notificationSubject.asObservable().pipe(share());
|
||||||
|
|
||||||
|
this.protocolService.serverMessage
|
||||||
|
.pipe(
|
||||||
|
filter(message => message.serviceType === SVC_TYPE_BUDDY),
|
||||||
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_BUDDY_UPD_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(
|
||||||
|
decodeUpdateNotification(message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_BUDDY_ADD_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(decodeAddNotification(message));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_BUDDY_DEL_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(decodeDelNotification(message));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
public add(req: AddRequest): Observable<AddResponse> {
|
public add(req: AddRequest): Observable<AddResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
|
|
|
@ -7,18 +7,26 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface AddRequest extends ProtocolRequest {
|
export interface AddRequest extends ProtocolRequest {
|
||||||
// 0. 동료그룹이름
|
/** 0. 동료그룹이름 */
|
||||||
groupName: string;
|
groupName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddResponse extends ProtocolResponse {
|
export interface AddResponse extends ProtocolResponse {
|
||||||
// 0: 동료그룹SEQ(n)
|
/** 0: 동료그룹SEQ(n) */
|
||||||
groupSeq: number;
|
groupSeq: number;
|
||||||
// 1: 동료그룹이름(s)
|
/** 1: 동료그룹이름(s) */
|
||||||
|
groupName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AddNotification extends ProtocolNotification {
|
||||||
|
/** 0: 동료그룹SEQ(n) */
|
||||||
|
groupSeq: number;
|
||||||
|
/** 1: 동료그룹이름(s) */
|
||||||
groupName: string;
|
groupName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,3 +46,12 @@ export const decodeAdd: ProtocolDecoder<AddResponse> = (
|
||||||
groupName: message.bodyList[1]
|
groupName: message.bodyList[1]
|
||||||
} as AddResponse);
|
} as AddResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeAddNotification: ProtocolDecoder<AddNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
groupSeq: message.bodyList[0],
|
||||||
|
groupName: message.bodyList[1]
|
||||||
|
} as AddNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -7,16 +7,22 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface DelRequest extends ProtocolRequest {
|
export interface DelRequest extends ProtocolRequest {
|
||||||
// 0: 동료그룹SEQ(n)
|
/** 동료그룹SEQ(n) */
|
||||||
groupSeq: number;
|
groupSeq: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DelResponse extends ProtocolResponse {
|
export interface DelResponse extends ProtocolResponse {
|
||||||
// 0: 동료그룹SEQ(n)
|
/** 동료그룹SEQ(n) */
|
||||||
|
groupSeq: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DelNotification extends ProtocolNotification {
|
||||||
|
/** 동료그룹SEQ(n) */
|
||||||
groupSeq: number;
|
groupSeq: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,3 +41,11 @@ export const decodeDel: ProtocolDecoder<DelResponse> = (
|
||||||
groupSeq: message.bodyList[0]
|
groupSeq: message.bodyList[0]
|
||||||
} as DelResponse);
|
} as DelResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeDelNotification: ProtocolDecoder<DelNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
groupSeq: message.bodyList[0]
|
||||||
|
} as DelNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -7,24 +7,34 @@ import {
|
||||||
PacketBodyValue,
|
PacketBodyValue,
|
||||||
ProtocolDecoder,
|
ProtocolDecoder,
|
||||||
ProtocolMessage,
|
ProtocolMessage,
|
||||||
decodeProtocolMessage
|
decodeProtocolMessage,
|
||||||
|
ProtocolNotification
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
export interface UpdateRequest extends ProtocolRequest {
|
export interface UpdateRequest extends ProtocolRequest {
|
||||||
// 0: 동료그룹SEQ(n)
|
/** 0: 동료그룹SEQ(n) */
|
||||||
groupSeq: number;
|
groupSeq: number;
|
||||||
// 1: 동료그룹이름(s)
|
/** 1: 동료그룹이름(s) */
|
||||||
groupName: string;
|
groupName: string;
|
||||||
// 2n: 사용자SEQ(n)...
|
/** 2n: 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateResponse extends ProtocolResponse {
|
export interface UpdateResponse extends ProtocolResponse {
|
||||||
// 0: 동료그룹SEQ(n)
|
/** 0: 동료그룹SEQ(n) */
|
||||||
groupSeq: number;
|
groupSeq: number;
|
||||||
// 1: 동료그룹이름(s)
|
/** 1: 동료그룹이름(s) */
|
||||||
groupName: string;
|
groupName: string;
|
||||||
// 2n: 사용자SEQ(n)...
|
/** 2n: 사용자SEQ(n)... */
|
||||||
|
userSeqs: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateNotification extends ProtocolNotification {
|
||||||
|
/** 0: 동료그룹SEQ(n) */
|
||||||
|
groupSeq: number;
|
||||||
|
/** 1: 동료그룹이름(s) */
|
||||||
|
groupName: string;
|
||||||
|
/** 2n: 사용자SEQ(n)... */
|
||||||
userSeqs: number[];
|
userSeqs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,3 +100,18 @@ export const decodeUpdate2: ProtocolDecoder<UpdateResponse> = (
|
||||||
userSeqs: userSeqArray
|
userSeqs: userSeqArray
|
||||||
} as UpdateResponse);
|
} as UpdateResponse);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const decodeUpdate2Notification: ProtocolDecoder<UpdateNotification> = (
|
||||||
|
message: ProtocolMessage
|
||||||
|
) => {
|
||||||
|
let userSeqArray: number[] = [];
|
||||||
|
if (message.bodyList.length > 2) {
|
||||||
|
userSeqArray = message.bodyList.slice(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return decodeProtocolMessage(message, {
|
||||||
|
groupSeq: message.bodyList[0],
|
||||||
|
groupName: message.bodyList[1],
|
||||||
|
userSeqs: userSeqArray
|
||||||
|
} as UpdateNotification);
|
||||||
|
};
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
|
import {
|
||||||
|
SSVC_TYPE_GROUP_UPD_RES2,
|
||||||
|
SSVC_TYPE_GROUP_ADD_RES,
|
||||||
|
SSVC_TYPE_GROUP_DEL_RES
|
||||||
|
} from './../types/service';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { map, take } from 'rxjs/operators';
|
import { map, take, share, filter, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
import {
|
import {
|
||||||
|
@ -15,13 +20,17 @@ import {
|
||||||
AddRequest,
|
AddRequest,
|
||||||
encodeAdd,
|
encodeAdd,
|
||||||
decodeAdd,
|
decodeAdd,
|
||||||
AddResponse
|
AddResponse,
|
||||||
|
decodeAddNotification,
|
||||||
|
AddNotification
|
||||||
} from '../protocols/add';
|
} from '../protocols/add';
|
||||||
import {
|
import {
|
||||||
DelRequest,
|
DelRequest,
|
||||||
encodeDel,
|
encodeDel,
|
||||||
decodeDel,
|
decodeDel,
|
||||||
DelResponse
|
DelResponse,
|
||||||
|
decodeDelNotification,
|
||||||
|
DelNotification
|
||||||
} from '../protocols/del';
|
} from '../protocols/del';
|
||||||
import {
|
import {
|
||||||
UpdateRequest,
|
UpdateRequest,
|
||||||
|
@ -29,13 +38,54 @@ import {
|
||||||
decodeUpdate,
|
decodeUpdate,
|
||||||
encodeUpdate2,
|
encodeUpdate2,
|
||||||
decodeUpdate2,
|
decodeUpdate2,
|
||||||
UpdateResponse
|
UpdateResponse,
|
||||||
|
UpdateNotification,
|
||||||
|
decodeUpdate2Notification
|
||||||
} from '../protocols/update';
|
} from '../protocols/update';
|
||||||
|
|
||||||
|
type Notifications = UpdateNotification | AddNotification | DelNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class GroupProtocolService {
|
export class GroupProtocolService {
|
||||||
constructor(private protocolService: ProtocolService) {}
|
private notificationSubject: Subject<Notifications>;
|
||||||
|
public notification$: Observable<Notifications>;
|
||||||
|
|
||||||
|
constructor(private protocolService: ProtocolService) {
|
||||||
|
this.notificationSubject = new Subject();
|
||||||
|
this.notification$ = this.notificationSubject.asObservable().pipe(share());
|
||||||
|
|
||||||
|
this.protocolService.serverMessage
|
||||||
|
.pipe(
|
||||||
|
filter(message => message.serviceType === SVC_TYPE_GROUP),
|
||||||
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_GROUP_UPD_RES2:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(
|
||||||
|
decodeUpdate2Notification(message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_GROUP_ADD_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(decodeAddNotification(message));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_GROUP_DEL_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next(decodeDelNotification(message));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
public add(req: AddRequest): Observable<AddResponse> {
|
public add(req: AddRequest): Observable<AddResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
|
|
|
@ -103,11 +103,14 @@ import {
|
||||||
encodeUpdateFont,
|
encodeUpdateFont,
|
||||||
decodeUpdateFont,
|
decodeUpdateFont,
|
||||||
decodeUpdateFontNotification,
|
decodeUpdateFontNotification,
|
||||||
UpdateFontNotification
|
UpdateFontNotification,
|
||||||
|
decodeUpdateNotification,
|
||||||
|
UpdateNotification
|
||||||
} from '../protocols/update';
|
} from '../protocols/update';
|
||||||
|
|
||||||
type Notifications =
|
type Notifications =
|
||||||
| UpdateFontNotification
|
| UpdateFontNotification
|
||||||
|
| UpdateNotification
|
||||||
| InviteNotification
|
| InviteNotification
|
||||||
| ExitNotification
|
| ExitNotification
|
||||||
| ExitForcingNotification;
|
| ExitForcingNotification;
|
||||||
|
@ -130,7 +133,9 @@ export class RoomProtocolService {
|
||||||
switch (message.subServiceType) {
|
switch (message.subServiceType) {
|
||||||
case SSVC_TYPE_ROOM_UPD_RES:
|
case SSVC_TYPE_ROOM_UPD_RES:
|
||||||
{
|
{
|
||||||
this.notificationSubject.next(decodeUpdate(message));
|
this.notificationSubject.next(
|
||||||
|
decodeUpdateNotification(message)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSVC_TYPE_ROOM_INVITE_NOTI:
|
case SSVC_TYPE_ROOM_INVITE_NOTI:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user