diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index 2a48dbe0..14963bbb 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -96,7 +96,9 @@ import { StringUtil } from '@ucap-webmessenger/ui'; import { UmgProtocolService, SSVC_TYPE_UMG_NOTI, - UmgNotiNotification + UmgNotiNotification, + SSVC_TYPE_UMG_DELETE_NOTI, + UmgDeleteNotiNotification } from '@ucap-webmessenger/protocol-umg'; import { LocalStorageService, @@ -647,6 +649,24 @@ export class AppNotificationService { } } break; + case SSVC_TYPE_UMG_DELETE_NOTI: + { + const noti = notiOrRes as UmgDeleteNotiNotification; + this.logger.debug( + 'Notification::umgProtocolService::UmgDeleteNotiNotification', + noti + ); + + console.log('TODO :: remove state logic'); + // // Receive Message List refresh.. + // this.store.dispatch( + // MessageStore.retrieveMessage({ + // messageType: MessageType.Receive + // }) + // ); + } + break; + default: break; } diff --git a/projects/ucap-webmessenger-protocol-umg/src/lib/protocols/del-noti.ts b/projects/ucap-webmessenger-protocol-umg/src/lib/protocols/del-noti.ts new file mode 100644 index 00000000..2dd105be --- /dev/null +++ b/projects/ucap-webmessenger-protocol-umg/src/lib/protocols/del-noti.ts @@ -0,0 +1,36 @@ +import { + ProtocolDecoder, + ProtocolMessage, + BodyStringDivider, + ProtocolNotification, + decodeProtocolMessage +} from '@ucap-webmessenger/protocol'; +import { SenderInfo } from '../models/sender-info'; + +export interface UmgDeleteNotiNotification extends ProtocolNotification { + /** 송신자SEQ(n) */ + senderSeq: number; + /** { 송신자정보 } */ + senderInfo: SenderInfo; +} + +export const decodeUmgDeleteNotiNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + let senderInfo: SenderInfo; + if (message.bodyList.length > 1) { + const info = message.bodyList[1].split(BodyStringDivider); + senderInfo = { + seq: Number(info[0]), + name: info[1], + profileImageFile: info[2], + grade: info[3] + }; + } + return decodeProtocolMessage(message, { + /** 송신자SEQ(n) */ + senderSeq: Number(message.bodyList[0]), + /** { 송신자정보 } */ + senderInfo + } as UmgDeleteNotiNotification); +}; diff --git a/projects/ucap-webmessenger-protocol-umg/src/lib/services/umg-protocol.service.ts b/projects/ucap-webmessenger-protocol-umg/src/lib/services/umg-protocol.service.ts index 5e08eacc..91fa71ec 100644 --- a/projects/ucap-webmessenger-protocol-umg/src/lib/services/umg-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-umg/src/lib/services/umg-protocol.service.ts @@ -6,9 +6,17 @@ import { } from '../protocols/noti'; import { ProtocolService } from '@ucap-webmessenger/protocol'; import { share, filter, tap } from 'rxjs/operators'; -import { SVC_TYPE_UMG, SSVC_TYPE_UMG_NOTI } from '../types/service'; +import { + SVC_TYPE_UMG, + SSVC_TYPE_UMG_NOTI, + SSVC_TYPE_UMG_DELETE_NOTI +} from '../types/service'; +import { + decodeUmgDeleteNotiNotification, + UmgDeleteNotiNotification +} from '../protocols/del-noti'; -type Notifications = UmgNotiNotification; +type Notifications = UmgNotiNotification | UmgDeleteNotiNotification; @Injectable({ providedIn: 'root' @@ -34,6 +42,14 @@ export class UmgProtocolService { } break; + case SSVC_TYPE_UMG_DELETE_NOTI: + { + this.notificationSubject.next( + decodeUmgDeleteNotiNotification(message) + ); + } + break; + default: break; } diff --git a/projects/ucap-webmessenger-protocol-umg/src/public-api.ts b/projects/ucap-webmessenger-protocol-umg/src/public-api.ts index 4e2e7302..b6ba2f74 100644 --- a/projects/ucap-webmessenger-protocol-umg/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-umg/src/public-api.ts @@ -4,6 +4,7 @@ export * from './lib/models/sender-info'; +export * from './lib/protocols/del-noti'; export * from './lib/protocols/noti'; export * from './lib/services/umg-protocol.service';