notification is implemented
This commit is contained in:
parent
036500f65e
commit
a3e2f252b7
@ -7,7 +7,9 @@ import { Store } from '@ngrx/store';
|
|||||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||||
import {
|
import {
|
||||||
SVC_TYPE_LOGOUT,
|
SVC_TYPE_LOGOUT,
|
||||||
SSVC_TYPE_LOGOUT_RES
|
SSVC_TYPE_LOGOUT_RES,
|
||||||
|
SSVC_TYPE_LOGOUT_REMOTE_NOTI,
|
||||||
|
AuthenticationProtocolService
|
||||||
} from '@ucap-webmessenger/protocol-authentication';
|
} from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
|
||||||
import * as AuthenticationStore from '../store/account/authentication';
|
import * as AuthenticationStore from '../store/account/authentication';
|
||||||
@ -16,17 +18,39 @@ import * as AuthenticationStore from '../store/account/authentication';
|
|||||||
export class AppService {
|
export class AppService {
|
||||||
constructor(
|
constructor(
|
||||||
private protocolService: ProtocolService,
|
private protocolService: ProtocolService,
|
||||||
|
private authenticationProtocolService: AuthenticationProtocolService,
|
||||||
private store: Store<any>
|
private store: Store<any>
|
||||||
) {
|
) {
|
||||||
this.protocolService.serverMessage
|
this.protocolService.serverMessage
|
||||||
.pipe(
|
.pipe(
|
||||||
|
filter(message => message.serviceType === SVC_TYPE_LOGOUT),
|
||||||
filter(
|
filter(
|
||||||
res =>
|
message =>
|
||||||
res.serviceType === SVC_TYPE_LOGOUT &&
|
message.subServiceType === SSVC_TYPE_LOGOUT_RES ||
|
||||||
res.subServiceType === SSVC_TYPE_LOGOUT_RES
|
message.subServiceType === SSVC_TYPE_LOGOUT_REMOTE_NOTI
|
||||||
),
|
),
|
||||||
tap(res => {
|
tap(message => {
|
||||||
|
switch (message.subServiceType) {
|
||||||
|
case SSVC_TYPE_LOGOUT_RES:
|
||||||
|
{
|
||||||
|
const logoutRes = this.authenticationProtocolService.decodeLogoutResponse(
|
||||||
|
message
|
||||||
|
);
|
||||||
this.store.dispatch(AuthenticationStore.logout());
|
this.store.dispatch(AuthenticationStore.logout());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_LOGOUT_REMOTE_NOTI:
|
||||||
|
{
|
||||||
|
const logoutRemoteNoti = this.authenticationProtocolService.decodeLogoutRemoteNotification(
|
||||||
|
message
|
||||||
|
);
|
||||||
|
this.store.dispatch(AuthenticationStore.logout());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol';
|
import { DeviceType } from '@ucap-webmessenger/core';
|
||||||
|
import {
|
||||||
|
ProtocolRequest,
|
||||||
|
ProtocolResponse,
|
||||||
|
ProtocolNotification
|
||||||
|
} from '@ucap-webmessenger/protocol';
|
||||||
|
|
||||||
// tslint:disable-next-line: no-empty-interface
|
// tslint:disable-next-line: no-empty-interface
|
||||||
export interface LogoutRequest extends ProtocolRequest {}
|
export interface LogoutRequest extends ProtocolRequest {}
|
||||||
|
|
||||||
// tslint:disable-next-line: no-empty-interface
|
// tslint:disable-next-line: no-empty-interface
|
||||||
export interface LogoutResponse extends ProtocolResponse {}
|
export interface LogoutResponse extends ProtocolResponse {}
|
||||||
|
|
||||||
|
export interface LogoutRemoteRequest extends ProtocolRequest {
|
||||||
|
targetDeviceType?: DeviceType;
|
||||||
|
requestDeviceType?: DeviceType;
|
||||||
|
}
|
||||||
|
export interface LogoutRemoteResponse extends ProtocolResponse {
|
||||||
|
targetDeviceType?: DeviceType;
|
||||||
|
resultCode?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LogoutRemoteNotification extends ProtocolNotification {
|
||||||
|
requestDeviceType?: DeviceType;
|
||||||
|
}
|
||||||
|
@ -6,17 +6,25 @@ import { map } from 'rxjs/operators';
|
|||||||
import {
|
import {
|
||||||
ProtocolService,
|
ProtocolService,
|
||||||
PacketBody,
|
PacketBody,
|
||||||
PacketBodyValue
|
PacketBodyValue,
|
||||||
|
ServerMessage
|
||||||
} from '@ucap-webmessenger/protocol';
|
} from '@ucap-webmessenger/protocol';
|
||||||
import { LoginRequest, LoginResponse } from '../models/login';
|
import { LoginRequest, LoginResponse } from '../models/login';
|
||||||
import {
|
import {
|
||||||
SVC_TYPE_LOGIN,
|
SVC_TYPE_LOGIN,
|
||||||
SSVC_TYPE_LOGIN_REQ,
|
SSVC_TYPE_LOGIN_REQ,
|
||||||
SVC_TYPE_LOGOUT,
|
SVC_TYPE_LOGOUT,
|
||||||
SSVC_TYPE_LOGOUT_REQ
|
SSVC_TYPE_LOGOUT_REQ,
|
||||||
|
SSVC_TYPE_LOGOUT_REMOTE_REQ
|
||||||
} from '../types/service';
|
} from '../types/service';
|
||||||
import { RoleCode } from '../types/role-code';
|
import { RoleCode } from '../types/role-code';
|
||||||
import { LogoutRequest, LogoutResponse } from '../models/logout';
|
import {
|
||||||
|
LogoutRequest,
|
||||||
|
LogoutResponse,
|
||||||
|
LogoutRemoteRequest,
|
||||||
|
LogoutRemoteResponse,
|
||||||
|
LogoutRemoteNotification
|
||||||
|
} from '../models/logout';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -58,53 +66,97 @@ export class AuthenticationProtocolService {
|
|||||||
.call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...bodyList)
|
.call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...bodyList)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(res => {
|
map(res => {
|
||||||
return {
|
return this.decodeLoginResponse(res);
|
||||||
loginId: res.bodyList[0],
|
|
||||||
userSeq: res.bodyList[1],
|
|
||||||
userInfo: res.bodyList[2],
|
|
||||||
token: res.bodyList[3],
|
|
||||||
companyCode: res.bodyList[4],
|
|
||||||
departmentCode: res.bodyList[5],
|
|
||||||
userId: res.bodyList[6],
|
|
||||||
passwordEncodingType: res.bodyList[7],
|
|
||||||
encriptionKey: res.bodyList[8],
|
|
||||||
existingPid: res.bodyList[9] === 'Y' ? true : false,
|
|
||||||
roleCode: res.bodyList[10] as RoleCode,
|
|
||||||
statusMessage1: res.bodyList[11],
|
|
||||||
statusMessage2: res.bodyList[12],
|
|
||||||
statusMessage3: res.bodyList[13],
|
|
||||||
fileDownloadAllow: res.bodyList[14] === 'Y' ? true : false,
|
|
||||||
fileRetentionPeriod: res.bodyList[15],
|
|
||||||
passwordValidityPeriod: res.bodyList[16],
|
|
||||||
privateInformationAgree: res.bodyList[17] === 'Y' ? true : false,
|
|
||||||
madn: res.bodyList[18],
|
|
||||||
hardPhoneSadn: res.bodyList[19],
|
|
||||||
fmcSadn: res.bodyList[20],
|
|
||||||
pbxIndex: res.bodyList[21],
|
|
||||||
passwordExpired: res.bodyList[22] === 'Y' ? true : false,
|
|
||||||
validAccount: res.bodyList[23] === 'Y' ? true : false,
|
|
||||||
validDevice: res.bodyList[24] === 'Y' ? true : false,
|
|
||||||
useableDevice: res.bodyList[25] === 'Y' ? true : false,
|
|
||||||
deviceScreenForcedLock: res.bodyList[26] === 'Y' ? true : false,
|
|
||||||
tokenString: res.bodyList[27],
|
|
||||||
havePermissionsForIntegratedMessageBox:
|
|
||||||
res.bodyList[28] === 'Y' ? true : false,
|
|
||||||
talkWithMeBotSeq: res.bodyList[29],
|
|
||||||
pinCode: res.bodyList[30],
|
|
||||||
permissionsForViewSchedule: res.bodyList[31],
|
|
||||||
havePermissionsForDevice: res.bodyList[32] === 'Y' ? true : false
|
|
||||||
} as LoginResponse;
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public decodeLoginResponse(message: ServerMessage): LoginResponse {
|
||||||
|
return {
|
||||||
|
loginId: message.bodyList[0],
|
||||||
|
userSeq: message.bodyList[1],
|
||||||
|
userInfo: message.bodyList[2],
|
||||||
|
token: message.bodyList[3],
|
||||||
|
companyCode: message.bodyList[4],
|
||||||
|
departmentCode: message.bodyList[5],
|
||||||
|
userId: message.bodyList[6],
|
||||||
|
passwordEncodingType: message.bodyList[7],
|
||||||
|
encriptionKey: message.bodyList[8],
|
||||||
|
existingPid: message.bodyList[9] === 'Y' ? true : false,
|
||||||
|
roleCode: message.bodyList[10] as RoleCode,
|
||||||
|
statusMessage1: message.bodyList[11],
|
||||||
|
statusMessage2: message.bodyList[12],
|
||||||
|
statusMessage3: message.bodyList[13],
|
||||||
|
fileDownloadAllow: message.bodyList[14] === 'Y' ? true : false,
|
||||||
|
fileRetentionPeriod: message.bodyList[15],
|
||||||
|
passwordValidityPeriod: message.bodyList[16],
|
||||||
|
privateInformationAgree: message.bodyList[17] === 'Y' ? true : false,
|
||||||
|
madn: message.bodyList[18],
|
||||||
|
hardPhoneSadn: message.bodyList[19],
|
||||||
|
fmcSadn: message.bodyList[20],
|
||||||
|
pbxIndex: message.bodyList[21],
|
||||||
|
passwordExpired: message.bodyList[22] === 'Y' ? true : false,
|
||||||
|
validAccount: message.bodyList[23] === 'Y' ? true : false,
|
||||||
|
validDevice: message.bodyList[24] === 'Y' ? true : false,
|
||||||
|
useableDevice: message.bodyList[25] === 'Y' ? true : false,
|
||||||
|
deviceScreenForcedLock: message.bodyList[26] === 'Y' ? true : false,
|
||||||
|
tokenString: message.bodyList[27],
|
||||||
|
havePermissionsForIntegratedMessageBox:
|
||||||
|
message.bodyList[28] === 'Y' ? true : false,
|
||||||
|
talkWithMeBotSeq: message.bodyList[29],
|
||||||
|
pinCode: message.bodyList[30],
|
||||||
|
permissionsForViewSchedule: message.bodyList[31],
|
||||||
|
havePermissionsForDevice: message.bodyList[32] === 'Y' ? true : false
|
||||||
|
} as LoginResponse;
|
||||||
|
}
|
||||||
|
|
||||||
public logout(req: LogoutRequest): Observable<LogoutResponse> {
|
public logout(req: LogoutRequest): Observable<LogoutResponse> {
|
||||||
return this.protocolService
|
return this.protocolService
|
||||||
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ)
|
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(res => {
|
map(res => {
|
||||||
return {} as LogoutResponse;
|
return this.decodeLogoutResponse(res);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public decodeLogoutResponse(message: ServerMessage): LogoutResponse {
|
||||||
|
return {} as LogoutResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public logoutRemote(
|
||||||
|
req: LogoutRemoteRequest
|
||||||
|
): Observable<LogoutRemoteResponse> {
|
||||||
|
const bodyList: PacketBody[] = [];
|
||||||
|
|
||||||
|
bodyList.push(
|
||||||
|
{ type: PacketBodyValue.String, value: req.targetDeviceType },
|
||||||
|
{ type: PacketBodyValue.String, value: req.requestDeviceType }
|
||||||
|
);
|
||||||
|
|
||||||
|
return this.protocolService
|
||||||
|
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REMOTE_REQ, ...bodyList)
|
||||||
|
.pipe(
|
||||||
|
map(res => {
|
||||||
|
return this.decodeLogoutRemoteResponse(res);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public decodeLogoutRemoteResponse(
|
||||||
|
message: ServerMessage
|
||||||
|
): LogoutRemoteResponse {
|
||||||
|
return {
|
||||||
|
targetDeviceType: message.bodyList[0],
|
||||||
|
resultCode: message.bodyList[1]
|
||||||
|
} as LogoutRemoteResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public decodeLogoutRemoteNotification(
|
||||||
|
message: ServerMessage
|
||||||
|
): LogoutRemoteNotification {
|
||||||
|
return {
|
||||||
|
requestDeviceType: message.bodyList[0]
|
||||||
|
} as LogoutRemoteNotification;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,3 +5,6 @@ export interface ProtocolRequest {
|
|||||||
export interface ProtocolResponse {
|
export interface ProtocolResponse {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line: no-empty-interface
|
||||||
|
export interface ProtocolNotification {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user