Notification is implemented
This commit is contained in:
parent
fad0787266
commit
817efad9df
|
@ -13,7 +13,7 @@
|
||||||
></app-layout-messenger-messages>
|
></app-layout-messenger-messages>
|
||||||
</div>
|
</div>
|
||||||
<mat-drawer #drawer mode="side" position="end">
|
<mat-drawer #drawer mode="side" position="end">
|
||||||
<p>sidenav</p>
|
<p>Auto-resizing sidenav</p>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
</mat-drawer-container>
|
</mat-drawer-container>
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,53 @@ import {
|
||||||
LogoutRemoteNotification
|
LogoutRemoteNotification
|
||||||
} from '@ucap-webmessenger/protocol-authentication';
|
} from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
|
||||||
import * as AuthenticationStore from '../store/account/authentication';
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
import {
|
||||||
|
EventProtocolService,
|
||||||
|
SSVC_TYPE_EVENT_SEND_NOTI,
|
||||||
|
SendNotification,
|
||||||
|
SSVC_TYPE_EVENT_READ_NOTI,
|
||||||
|
SSVC_TYPE_EVENT_CANCEL_NOTI,
|
||||||
|
SSVC_TYPE_EVENT_DEL_RES
|
||||||
|
} from '@ucap-webmessenger/protocol-event';
|
||||||
|
import {
|
||||||
|
InfoProtocolService,
|
||||||
|
SSVC_TYPE_INFO_USER_NOTI,
|
||||||
|
UserNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-info';
|
||||||
|
import {
|
||||||
|
RoomProtocolService,
|
||||||
|
SSVC_TYPE_ROOM_INVITE_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_EXIT_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_EXIT_FORCING_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_FONT_UPD_NOTI,
|
||||||
|
InviteNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
|
import {
|
||||||
|
StatusProtocolService,
|
||||||
|
SSVC_TYPE_STATUS_NOTI,
|
||||||
|
StatusNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-status';
|
||||||
|
import {
|
||||||
|
ReadNotification,
|
||||||
|
CancelNotification,
|
||||||
|
DelNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-event';
|
||||||
|
import {
|
||||||
|
ExitNotification,
|
||||||
|
ExitForcingNotification,
|
||||||
|
UpdateFontNotification
|
||||||
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppNotificationService {
|
export class AppNotificationService {
|
||||||
constructor(
|
constructor(
|
||||||
private authenticationProtocolService: AuthenticationProtocolService,
|
private authenticationProtocolService: AuthenticationProtocolService,
|
||||||
|
private eventProtocolService: EventProtocolService,
|
||||||
|
private infoProtocolService: InfoProtocolService,
|
||||||
|
private roomProtocolService: RoomProtocolService,
|
||||||
|
private statusProtocolService: StatusProtocolService,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
private logger: NGXLogger
|
private logger: NGXLogger
|
||||||
) {}
|
) {}
|
||||||
|
@ -31,11 +71,19 @@ export class AppNotificationService {
|
||||||
case SSVC_TYPE_LOGOUT_RES:
|
case SSVC_TYPE_LOGOUT_RES:
|
||||||
{
|
{
|
||||||
const res = notiOrRes as LogoutResponse;
|
const res = notiOrRes as LogoutResponse;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::authenticationProtocolService::LogoutResponse',
|
||||||
|
res
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSVC_TYPE_LOGOUT_REMOTE_NOTI:
|
case SSVC_TYPE_LOGOUT_REMOTE_NOTI:
|
||||||
{
|
{
|
||||||
const noti = notiOrRes as LogoutRemoteNotification;
|
const noti = notiOrRes as LogoutRemoteNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::authenticationProtocolService::LogoutRemoteNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -45,5 +93,136 @@ export class AppNotificationService {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
|
this.eventProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
tap(notiOrRes => {
|
||||||
|
switch (notiOrRes.Type) {
|
||||||
|
case SSVC_TYPE_EVENT_SEND_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as SendNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::eventProtocolService::SendNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_EVENT_READ_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as ReadNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::eventProtocolService::ReadNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_EVENT_CANCEL_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as CancelNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::eventProtocolService::CancelNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_EVENT_DEL_RES:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as DelNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::eventProtocolService::DelNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
this.infoProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
tap(notiOrRes => {
|
||||||
|
switch (notiOrRes.Type) {
|
||||||
|
case SSVC_TYPE_INFO_USER_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as UserNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::infoProtocolService::UserNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
this.roomProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
tap(notiOrRes => {
|
||||||
|
switch (notiOrRes.Type) {
|
||||||
|
case SSVC_TYPE_ROOM_INVITE_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as InviteNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::roomProtocolService::InviteNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_EXIT_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as ExitNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::roomProtocolService::ExitNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_EXIT_FORCING_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as ExitForcingNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::roomProtocolService::ExitForcingNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_FONT_UPD_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as UpdateFontNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::roomProtocolService::UpdateFontNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
this.statusProtocolService.notification$
|
||||||
|
.pipe(
|
||||||
|
tap(notiOrRes => {
|
||||||
|
switch (notiOrRes.Type) {
|
||||||
|
case SSVC_TYPE_STATUS_NOTI:
|
||||||
|
{
|
||||||
|
const noti = notiOrRes as StatusNotification;
|
||||||
|
this.logger.debug(
|
||||||
|
'Notification::statusProtocolService::StatusNotification',
|
||||||
|
noti
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,14 @@ import {
|
||||||
LogoutRemoteNotification
|
LogoutRemoteNotification
|
||||||
} from '../protocols/logout-remote';
|
} from '../protocols/logout-remote';
|
||||||
|
|
||||||
|
type Notifications = LogoutResponse | LogoutRemoteNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AuthenticationProtocolService {
|
export class AuthenticationProtocolService {
|
||||||
private logoutNotificationSubject: Subject<
|
private logoutNotificationSubject: Subject<Notifications>;
|
||||||
LogoutResponse | LogoutRemoteNotification
|
public logoutNotification$: Observable<Notifications>;
|
||||||
>;
|
|
||||||
public logoutNotification$: Observable<
|
|
||||||
LogoutResponse | LogoutRemoteNotification
|
|
||||||
>;
|
|
||||||
|
|
||||||
constructor(private protocolService: ProtocolService) {
|
constructor(private protocolService: ProtocolService) {
|
||||||
this.logoutNotificationSubject = new Subject();
|
this.logoutNotificationSubject = new Subject();
|
||||||
|
|
|
@ -31,20 +31,27 @@ import {
|
||||||
SSVC_TYPE_EVENT_READ_REQ,
|
SSVC_TYPE_EVENT_READ_REQ,
|
||||||
SSVC_TYPE_EVENT_DEL_REQ,
|
SSVC_TYPE_EVENT_DEL_REQ,
|
||||||
SSVC_TYPE_EVENT_CANCEL_REQ,
|
SSVC_TYPE_EVENT_CANCEL_REQ,
|
||||||
SSVC_TYPE_EVENT_CANCEL_NOTI
|
SSVC_TYPE_EVENT_CANCEL_NOTI,
|
||||||
|
SSVC_TYPE_EVENT_SEND_NOTI,
|
||||||
|
SSVC_TYPE_EVENT_READ_NOTI,
|
||||||
|
SSVC_TYPE_EVENT_DEL_RES
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
import {
|
import {
|
||||||
SendRequest,
|
SendRequest,
|
||||||
SendResponse,
|
SendResponse,
|
||||||
decodeSend,
|
decodeSend,
|
||||||
encodeSend
|
encodeSend,
|
||||||
|
decodeSendNotification,
|
||||||
|
SendNotification
|
||||||
} from '../protocols/send';
|
} from '../protocols/send';
|
||||||
import { PushRequest, encodePush } from '../protocols/push';
|
import { PushRequest, encodePush } from '../protocols/push';
|
||||||
import {
|
import {
|
||||||
ReadResponse,
|
ReadResponse,
|
||||||
ReadRequest,
|
ReadRequest,
|
||||||
encodeRead,
|
encodeRead,
|
||||||
decodeRead
|
decodeRead,
|
||||||
|
decodeReadNotification,
|
||||||
|
ReadNotification
|
||||||
} from '../protocols/read';
|
} from '../protocols/read';
|
||||||
import {
|
import {
|
||||||
DelRequest,
|
DelRequest,
|
||||||
|
@ -60,33 +67,62 @@ import {
|
||||||
CancelNotification,
|
CancelNotification,
|
||||||
decodeCancelNotification
|
decodeCancelNotification
|
||||||
} from '../protocols/cancel';
|
} from '../protocols/cancel';
|
||||||
|
import { decodeDelNotification, DelNotification } from '../protocols/del';
|
||||||
|
|
||||||
|
type Notifications =
|
||||||
|
| SendNotification
|
||||||
|
| ReadNotification
|
||||||
|
| CancelNotification
|
||||||
|
| DelNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class EventProtocolService {
|
export class EventProtocolService {
|
||||||
private eventNotificationSubject: Subject<CancelNotification>;
|
private notificationSubject: Subject<Notifications>;
|
||||||
public eventNotification$: Observable<CancelNotification>;
|
public notification$: Observable<Notifications>;
|
||||||
|
|
||||||
constructor(private protocolService: ProtocolService) {
|
constructor(private protocolService: ProtocolService) {
|
||||||
this.eventNotificationSubject = new Subject();
|
this.notificationSubject = new Subject();
|
||||||
this.eventNotification$ = this.eventNotificationSubject
|
this.notification$ = this.notificationSubject.asObservable().pipe(share());
|
||||||
.asObservable()
|
|
||||||
.pipe(share());
|
|
||||||
|
|
||||||
this.protocolService.serverMessage
|
this.protocolService.serverMessage
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(message => message.serviceType === SVC_TYPE_EVENT),
|
filter(message => message.serviceType === SVC_TYPE_EVENT),
|
||||||
tap(message => {
|
tap(message => {
|
||||||
switch (message.subServiceType) {
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_EVENT_SEND_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeSendNotification(message),
|
||||||
|
Type: SSVC_TYPE_EVENT_SEND_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_EVENT_READ_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeReadNotification(message),
|
||||||
|
Type: SSVC_TYPE_EVENT_READ_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SSVC_TYPE_EVENT_CANCEL_NOTI:
|
case SSVC_TYPE_EVENT_CANCEL_NOTI:
|
||||||
{
|
{
|
||||||
this.eventNotificationSubject.next({
|
this.notificationSubject.next({
|
||||||
...decodeCancelNotification(message),
|
...decodeCancelNotification(message),
|
||||||
Type: SSVC_TYPE_EVENT_CANCEL_NOTI
|
Type: SSVC_TYPE_EVENT_CANCEL_NOTI
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SSVC_TYPE_EVENT_DEL_RES:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeDelNotification(message),
|
||||||
|
Type: SSVC_TYPE_EVENT_DEL_RES
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,18 @@
|
||||||
|
|
||||||
export * from './lib/models/info';
|
export * from './lib/models/info';
|
||||||
|
|
||||||
|
export * from './lib/protocols/cancel';
|
||||||
|
export * from './lib/protocols/del';
|
||||||
export * from './lib/protocols/info';
|
export * from './lib/protocols/info';
|
||||||
|
export * from './lib/protocols/push';
|
||||||
|
export * from './lib/protocols/read';
|
||||||
export * from './lib/protocols/send';
|
export * from './lib/protocols/send';
|
||||||
|
|
||||||
export * from './lib/services/event-protocol.service';
|
export * from './lib/services/event-protocol.service';
|
||||||
|
|
||||||
export * from './lib/ucap-event-protocol.module';
|
|
||||||
|
|
||||||
export * from './lib/types/event.type';
|
export * from './lib/types/event.type';
|
||||||
export * from './lib/types/push-cl.type';
|
export * from './lib/types/push-cl.type';
|
||||||
export * from './lib/types/push-status.type';
|
export * from './lib/types/push-status.type';
|
||||||
export * from './lib/types/service';
|
export * from './lib/types/service';
|
||||||
|
|
||||||
|
export * from './lib/ucap-event-protocol.module';
|
||||||
|
|
|
@ -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';
|
||||||
import {
|
import {
|
||||||
|
@ -9,13 +9,16 @@ import {
|
||||||
SSVC_TYPE_INFO_USER_REQ,
|
SSVC_TYPE_INFO_USER_REQ,
|
||||||
SSVC_TYPE_INFO_STATE_REQ,
|
SSVC_TYPE_INFO_STATE_REQ,
|
||||||
SSVC_TYPE_INFO_USER_OPTION_REQ,
|
SSVC_TYPE_INFO_USER_OPTION_REQ,
|
||||||
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ
|
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ,
|
||||||
|
SSVC_TYPE_INFO_USER_NOTI
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
import {
|
import {
|
||||||
UserRequest,
|
UserRequest,
|
||||||
encodeUser,
|
encodeUser,
|
||||||
UserResponse,
|
UserResponse,
|
||||||
decodeUser
|
decodeUser,
|
||||||
|
decodeUserNotification,
|
||||||
|
UserNotification
|
||||||
} from '../protocols/user';
|
} from '../protocols/user';
|
||||||
import {
|
import {
|
||||||
StatusRequest,
|
StatusRequest,
|
||||||
|
@ -32,11 +35,40 @@ import {
|
||||||
decodeUserOptionUpdate
|
decodeUserOptionUpdate
|
||||||
} from '../protocols/user-option';
|
} from '../protocols/user-option';
|
||||||
|
|
||||||
|
type Notifications = UserNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class InfoProtocolService {
|
export class InfoProtocolService {
|
||||||
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_INFO),
|
||||||
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_INFO_USER_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeUserNotification(message),
|
||||||
|
Type: SSVC_TYPE_INFO_USER_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
public user(req: UserRequest): Observable<UserResponse> {
|
public user(req: UserRequest): Observable<UserResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
|
|
|
@ -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, takeWhile } from 'rxjs/operators';
|
import { map, take, takeWhile, share, tap, filter } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
import {
|
import {
|
||||||
|
@ -22,7 +22,11 @@ import {
|
||||||
SSVC_TYPE_ROOM_USER_STATUS_REQ,
|
SSVC_TYPE_ROOM_USER_STATUS_REQ,
|
||||||
SSVC_TYPE_ROOM_UPD_REQ,
|
SSVC_TYPE_ROOM_UPD_REQ,
|
||||||
SSVC_TYPE_ROOM_INFO_UPD_REQ,
|
SSVC_TYPE_ROOM_INFO_UPD_REQ,
|
||||||
SSVC_TYPE_ROOM_FONT_UPD_REQ
|
SSVC_TYPE_ROOM_FONT_UPD_REQ,
|
||||||
|
SSVC_TYPE_ROOM_INVITE_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_EXIT_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_EXIT_FORCING_NOTI,
|
||||||
|
SSVC_TYPE_ROOM_FONT_UPD_NOTI
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
import {
|
import {
|
||||||
OpenRequest,
|
OpenRequest,
|
||||||
|
@ -46,7 +50,9 @@ import {
|
||||||
InviteRequest,
|
InviteRequest,
|
||||||
InviteResponse,
|
InviteResponse,
|
||||||
encodeInvite,
|
encodeInvite,
|
||||||
decodeInvite
|
decodeInvite,
|
||||||
|
decodeInviteNotification,
|
||||||
|
InviteNotification
|
||||||
} from '../protocols/invite';
|
} from '../protocols/invite';
|
||||||
import {
|
import {
|
||||||
InfoRequest,
|
InfoRequest,
|
||||||
|
@ -76,7 +82,11 @@ import {
|
||||||
encodeExitForcing,
|
encodeExitForcing,
|
||||||
decodeExitForcing,
|
decodeExitForcing,
|
||||||
decodeAllExit,
|
decodeAllExit,
|
||||||
ExitAllResponse
|
ExitAllResponse,
|
||||||
|
decodeExitForcingNotification,
|
||||||
|
decodeExitNotification,
|
||||||
|
ExitNotification,
|
||||||
|
ExitForcingNotification
|
||||||
} from '../protocols/exit';
|
} from '../protocols/exit';
|
||||||
import {
|
import {
|
||||||
UpdateRequest,
|
UpdateRequest,
|
||||||
|
@ -90,14 +100,73 @@ import {
|
||||||
UpdateFontRequest,
|
UpdateFontRequest,
|
||||||
UpdateFontResponse,
|
UpdateFontResponse,
|
||||||
encodeUpdateFont,
|
encodeUpdateFont,
|
||||||
decodeUpdateFont
|
decodeUpdateFont,
|
||||||
|
decodeUpdateFontNotification,
|
||||||
|
UpdateFontNotification
|
||||||
} from '../protocols/update';
|
} from '../protocols/update';
|
||||||
|
|
||||||
|
type Notifications =
|
||||||
|
| UpdateFontNotification
|
||||||
|
| InviteNotification
|
||||||
|
| ExitNotification
|
||||||
|
| ExitForcingNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class RoomProtocolService {
|
export class RoomProtocolService {
|
||||||
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_ROOM),
|
||||||
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_ROOM_INVITE_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeInviteNotification(message),
|
||||||
|
Type: SSVC_TYPE_ROOM_INVITE_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_EXIT_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeExitNotification(message),
|
||||||
|
Type: SSVC_TYPE_ROOM_EXIT_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_EXIT_FORCING_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeExitForcingNotification(message),
|
||||||
|
Type: SSVC_TYPE_ROOM_EXIT_FORCING_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_ROOM_FONT_UPD_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeUpdateFontNotification(message),
|
||||||
|
Type: SSVC_TYPE_ROOM_FONT_UPD_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
public open(req: OpenRequest): Observable<OpenResponse> {
|
public open(req: OpenRequest): Observable<OpenResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
|
|
|
@ -6,11 +6,14 @@ export * from './lib/models/room-info';
|
||||||
export * from './lib/models/user-info';
|
export * from './lib/models/user-info';
|
||||||
export * from './lib/models/user-info-short';
|
export * from './lib/models/user-info-short';
|
||||||
|
|
||||||
|
export * from './lib/protocols/exit';
|
||||||
export * from './lib/protocols/info';
|
export * from './lib/protocols/info';
|
||||||
export * from './lib/protocols/invite';
|
export * from './lib/protocols/invite';
|
||||||
export * from './lib/protocols/open';
|
export * from './lib/protocols/open';
|
||||||
|
export * from './lib/protocols/update';
|
||||||
|
|
||||||
export * from './lib/services/room-protocol.service';
|
export * from './lib/services/room-protocol.service';
|
||||||
|
|
||||||
export * from './lib/types/employee.type';
|
export * from './lib/types/employee.type';
|
||||||
export * from './lib/types/room.type';
|
export * from './lib/types/room.type';
|
||||||
export * from './lib/types/service';
|
export * from './lib/types/service';
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { map, take, takeWhile } from 'rxjs/operators';
|
import { map, take, takeWhile, share, filter, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
import {
|
import {
|
||||||
StatusRequest,
|
StatusRequest,
|
||||||
encodeStatus,
|
encodeStatus,
|
||||||
decodeStatus,
|
decodeStatus,
|
||||||
StatusResponse
|
StatusResponse,
|
||||||
|
decodeStatusNotification,
|
||||||
|
StatusNotification
|
||||||
} from '../protocols/status';
|
} from '../protocols/status';
|
||||||
import {
|
import {
|
||||||
SVC_TYPE_STATUS,
|
SVC_TYPE_STATUS,
|
||||||
|
@ -19,7 +21,8 @@ import {
|
||||||
SSVC_TYPE_STATUS_BUDDY_REQ,
|
SSVC_TYPE_STATUS_BUDDY_REQ,
|
||||||
SSVC_TYPE_STATUS_MSG_UPD_REQ,
|
SSVC_TYPE_STATUS_MSG_UPD_REQ,
|
||||||
SSVC_TYPE_STATUS_SUBSCRIPT_REQ,
|
SSVC_TYPE_STATUS_SUBSCRIPT_REQ,
|
||||||
SSVC_TYPE_STATUS_UNSUBSCRIPT_REQ
|
SSVC_TYPE_STATUS_UNSUBSCRIPT_REQ,
|
||||||
|
SSVC_TYPE_STATUS_NOTI
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
import {
|
import {
|
||||||
BulkInfoRequest,
|
BulkInfoRequest,
|
||||||
|
@ -47,11 +50,40 @@ import {
|
||||||
encodeUnSubscribe
|
encodeUnSubscribe
|
||||||
} from '../protocols/unsubscribe';
|
} from '../protocols/unsubscribe';
|
||||||
|
|
||||||
|
type Notifications = StatusNotification;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class StatusProtocolService {
|
export class StatusProtocolService {
|
||||||
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_STATUS),
|
||||||
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_STATUS_NOTI:
|
||||||
|
{
|
||||||
|
this.notificationSubject.next({
|
||||||
|
...decodeStatusNotification(message),
|
||||||
|
Type: SSVC_TYPE_STATUS_NOTI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
public status(req: StatusRequest): Observable<StatusResponse> {
|
public status(req: StatusRequest): Observable<StatusResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
|
|
Loading…
Reference in New Issue
Block a user