API, PI, Protocol are refactored

This commit is contained in:
병준 박 2019-09-20 11:39:09 +09:00
parent ff33395a5f
commit a2db0ef3ca
33 changed files with 762 additions and 411 deletions

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileProfileSaveRequest extends APIRequest {
userSeq: string;
@ -14,3 +20,17 @@ export interface FileProfileSaveResponse extends APIResponse {
ProfileURL?: string;
ProfileSubDir?: string;
}
const fileProfileEncodeMap = {};
export const encodeFileProfileSave: APIEncoder<FileProfileSaveRequest> = (
req: FileProfileSaveRequest
) => {
return ParameterUtil.encode(fileProfileEncodeMap, req);
};
export const decodeFileProfileSave: APIDecoder<FileProfileSaveResponse> = (
res: any
) => {
return {} as FileProfileSaveResponse;
};

View File

@ -1,5 +1,5 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest } from '@ucap-webmessenger/api';
import { APIRequest, APIEncoder, ParameterUtil } from '@ucap-webmessenger/api';
export interface FileTalkDownloadRequest extends APIRequest {
userSeq: string;
@ -7,3 +7,11 @@ export interface FileTalkDownloadRequest extends APIRequest {
token: string;
attachmentsSeq?: string;
}
const fileTalkDownloadEncodeMap = {};
export const encodeFileTalkDownload: APIEncoder<FileTalkDownloadRequest> = (
req: FileTalkDownloadRequest
) => {
return ParameterUtil.encode(fileTalkDownloadEncodeMap, req);
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileTalkSaveRequest extends APIRequest {
userSeq: string;
@ -29,3 +35,17 @@ export interface FileTalkSaveResponse extends APIResponse {
VoiceTime?: string;
SynapKey?: string;
}
const fileTalkSaveEncodeMap = {};
export const encodeFileTalkSave: APIEncoder<FileTalkSaveRequest> = (
req: FileTalkSaveRequest
) => {
return ParameterUtil.encode(fileTalkSaveEncodeMap, req);
};
export const decodeFileTalkSave: APIDecoder<FileTalkSaveResponse> = (
res: any
) => {
return {} as FileTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface FileTalkShareRequest extends APIRequest {
userSeq: string;
@ -22,3 +28,17 @@ export interface FileTalkShareResponse extends APIResponse {
CompanyCode?: string;
SynapKey?: string;
}
const fileTalkShareEncodeMap = {};
export const encodeFileTalkShare: APIEncoder<FileTalkShareRequest> = (
req: FileTalkShareRequest
) => {
return ParameterUtil.encode(fileTalkShareEncodeMap, req);
};
export const decodeFileTalkShare: APIDecoder<FileTalkShareResponse> = (
res: any
) => {
return {} as FileTalkShareResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface MassTalkDownloadRequest extends APIRequest {
userSeq: string;
@ -13,3 +19,17 @@ export interface MassTalkDownloadResponse extends APIResponse {
UserName?: string;
RegDate?: string;
}
const massTalkDownloadEncodeMap = {};
export const encodeMassTalkDownload: APIEncoder<MassTalkDownloadRequest> = (
req: MassTalkDownloadRequest
) => {
return ParameterUtil.encode(massTalkDownloadEncodeMap, req);
};
export const decodeMassTalkDownload: APIDecoder<MassTalkDownloadResponse> = (
res: any
) => {
return {} as MassTalkDownloadResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface MassTalkSaveRequest extends APIRequest {
userSeq: string;
@ -15,3 +21,17 @@ export interface MassTalkSaveResponse extends APIResponse {
RegDate?: string;
Content?: string;
}
const massTalkSaveEncodeMap = {};
export const encodeMassTalkSave: APIEncoder<MassTalkSaveRequest> = (
req: MassTalkSaveRequest
) => {
return ParameterUtil.encode(massTalkSaveEncodeMap, req);
};
export const decodeMassTalkSave: APIDecoder<MassTalkSaveResponse> = (
res: any
) => {
return {} as MassTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TransMassTalkDownloadRequest extends APIRequest {
userSeq: string;
@ -15,3 +21,17 @@ export interface TransMassTalkDownloadResponse extends APIResponse {
UserName?: string;
RegDate?: string;
}
const transMassTalkDownloadEncodeMap = {};
export const encodeTransMassTalkDownload: APIEncoder<
TransMassTalkDownloadRequest
> = (req: TransMassTalkDownloadRequest) => {
return ParameterUtil.encode(transMassTalkDownloadEncodeMap, req);
};
export const decodeTransMassTalkDownload: APIDecoder<
TransMassTalkDownloadResponse
> = (res: any) => {
return {} as TransMassTalkDownloadResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TransMassTalkSaveRequest extends APIRequest {
userSeq: string;
@ -19,3 +25,17 @@ export interface TransMassTalkSaveResponse extends APIResponse {
Original?: string;
Translation?: string;
}
const transMassTalkSaveEncodeMap = {};
export const encodeTransMassTalkSave: APIEncoder<TransMassTalkSaveRequest> = (
req: TransMassTalkSaveRequest
) => {
return ParameterUtil.encode(transMassTalkSaveEncodeMap, req);
};
export const decodeTransMassTalkSave: APIDecoder<TransMassTalkSaveResponse> = (
res: any
) => {
return {} as TransMassTalkSaveResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TranslationReqRequest extends APIRequest {
userSeq: string;
@ -16,3 +22,17 @@ export interface TranslationReqResponse extends APIResponse {
Original?: string;
Translation?: string;
}
const translationReqEncodeMap = {};
export const encodeTranslationReq: APIEncoder<TranslationReqRequest> = (
req: TranslationReqRequest
) => {
return ParameterUtil.encode(translationReqEncodeMap, req);
};
export const decodeTranslationReq: APIDecoder<TranslationReqResponse> = (
res: any
) => {
return {} as TranslationReqResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface TranslationSaveRequest extends APIRequest {
userSeq: string;
@ -20,3 +26,17 @@ export interface TranslationSaveResponse extends APIResponse {
Original?: string;
Translation?: string;
}
const translationSaveEncodeMap = {};
export const encodeTranslationSave: APIEncoder<TranslationSaveRequest> = (
req: TranslationSaveRequest
) => {
return ParameterUtil.encode(translationSaveEncodeMap, req);
};
export const decodeTranslationSave: APIDecoder<TranslationSaveResponse> = (
res: any
) => {
return {} as TranslationSaveResponse;
};

View File

@ -8,40 +8,61 @@ import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config';
import {
FileProfileSaveRequest,
FileProfileSaveResponse
FileProfileSaveResponse,
encodeFileProfileSave,
decodeFileProfileSave
} from '../models/file-profile-save';
import { FileTalkDownloadRequest } from '../models/file-talk-download';
import {
FileTalkDownloadRequest,
encodeFileTalkDownload
} from '../models/file-talk-download';
import {
FileTalkSaveRequest,
FileTalkSaveResponse
FileTalkSaveResponse,
encodeFileTalkSave,
decodeFileTalkSave
} from '../models/file-talk-save';
import {
FileTalkShareRequest,
FileTalkShareResponse
FileTalkShareResponse,
encodeFileTalkShare,
decodeFileTalkShare
} from '../models/file-talk-share';
import {
MassTalkDownloadRequest,
MassTalkDownloadResponse
MassTalkDownloadResponse,
encodeMassTalkDownload,
decodeMassTalkDownload
} from '../models/mass-talk-download';
import {
MassTalkSaveRequest,
MassTalkSaveResponse
MassTalkSaveResponse,
encodeMassTalkSave,
decodeMassTalkSave
} from '../models/mass-talk-save';
import {
TransMassTalkDownloadRequest,
TransMassTalkDownloadResponse
TransMassTalkDownloadResponse,
encodeTransMassTalkDownload,
decodeTransMassTalkDownload
} from '../models/trans-mass-talk-download';
import {
TransMassTalkSaveRequest,
TransMassTalkSaveResponse
TransMassTalkSaveResponse,
encodeTransMassTalkSave,
decodeTransMassTalkSave
} from '../models/trans-mass-talk-save';
import {
TranslationReqRequest,
TranslationReqResponse
TranslationReqResponse,
encodeTranslationReq,
decodeTranslationReq
} from '../models/translation-req';
import {
TranslationSaveRequest,
TranslationSaveResponse
TranslationSaveResponse,
encodeTranslationSave,
decodeTranslationSave
} from '../models/translation-save';
@Injectable({
@ -61,14 +82,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileProfileSave,
{},
{
params: {}
params: encodeFileProfileSave(req)
}
)
.pipe(
map(res => {
return {} as FileProfileSaveResponse;
})
);
.pipe(map(res => decodeFileProfileSave(res)));
}
public fileTalkDownload(req: FileTalkDownloadRequest): Observable<Blob> {
@ -76,7 +93,7 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkDownload,
{ responseType: 'blob' },
{
params: {}
params: encodeFileTalkDownload(req)
}
);
}
@ -89,14 +106,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkSave,
{},
{
params: {}
params: encodeFileTalkSave(req)
}
)
.pipe(
map(res => {
return {} as FileTalkSaveResponse;
})
);
.pipe(map(res => decodeFileTalkSave(res)));
}
public fileTalkShare(
@ -107,14 +120,10 @@ export class CommonApiService {
this.moduleConfig.urls.fileTalkShare,
{},
{
params: {}
params: encodeFileTalkShare(req)
}
)
.pipe(
map(res => {
return {} as FileTalkShareResponse;
})
);
.pipe(map(res => decodeFileTalkShare(res)));
}
public massTalkDownload(
@ -125,14 +134,10 @@ export class CommonApiService {
this.moduleConfig.urls.massTalkDownload,
{},
{
params: {}
params: encodeMassTalkDownload(req)
}
)
.pipe(
map(res => {
return {} as MassTalkDownloadResponse;
})
);
.pipe(map(res => decodeMassTalkDownload(res)));
}
public massTalkSave(
@ -143,14 +148,10 @@ export class CommonApiService {
this.moduleConfig.urls.massTalkSave,
{},
{
params: {}
params: encodeMassTalkSave(req)
}
)
.pipe(
map(res => {
return {} as MassTalkSaveResponse;
})
);
.pipe(map(res => decodeMassTalkSave(res)));
}
public transMassTalkDownload(
@ -161,14 +162,10 @@ export class CommonApiService {
this.moduleConfig.urls.transMassTalkDownload,
{},
{
params: {}
params: encodeTransMassTalkDownload(req)
}
)
.pipe(
map(res => {
return {} as TransMassTalkDownloadResponse;
})
);
.pipe(map(res => decodeTransMassTalkDownload(res)));
}
public transMassTalkSave(
@ -179,14 +176,10 @@ export class CommonApiService {
this.moduleConfig.urls.transMassTalkSave,
{},
{
params: {}
params: encodeTransMassTalkSave(req)
}
)
.pipe(
map(res => {
return {} as TransMassTalkSaveResponse;
})
);
.pipe(map(res => decodeTransMassTalkSave(res)));
}
public translationReq(
@ -197,14 +190,10 @@ export class CommonApiService {
this.moduleConfig.urls.translationReq,
{},
{
params: {}
params: encodeTranslationReq(req)
}
)
.pipe(
map(res => {
return {} as TranslationReqResponse;
})
);
.pipe(map(res => decodeTranslationReq(res)));
}
public translationSave(
@ -215,13 +204,9 @@ export class CommonApiService {
this.moduleConfig.urls.translationSave,
{},
{
params: {}
params: encodeTranslationSave(req)
}
)
.pipe(
map(res => {
return {} as TranslationSaveResponse;
})
);
.pipe(map(res => decodeTranslationSave(res)));
}
}

View File

@ -1,4 +1,9 @@
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface CheckUserInfoExRequest extends APIRequest {
userId: string;
@ -9,3 +14,23 @@ export interface CheckUserInfoExRequest extends APIRequest {
export interface CheckUserInfoExResponse extends APIResponse {
userId?: string;
}
export const encodeCheckUserInfoEx: APIEncoder<CheckUserInfoExRequest> = (
req: CheckUserInfoExRequest
) => {
return {
p_user_id: req.userId,
p_comp_code: req.companyCode,
p_user_session: req.userSession
};
};
export const decodeCheckUserInfoEx: APIDecoder<CheckUserInfoExResponse> = (
res: any
) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
userId: res.UserID
} as CheckUserInfoExResponse;
};

View File

@ -1,5 +1,10 @@
import { AppType, DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface CompanyListRequest extends APIRequest {
userSeq?: string;
@ -21,3 +26,40 @@ export interface Company {
export interface CompanyListResponse extends APIResponse {
companyList?: Company[];
}
export const encodeCompanyList: APIEncoder<CompanyListRequest> = (
req: CompanyListRequest
) => {
return {
p_user_seq: req.userSeq,
p_app_type: req.appType,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_code: req.companyGroupCode
};
};
export const decodeCompanyList: APIDecoder<CompanyListResponse> = (
res: any
) => {
let companyList: Company[] | undefined;
if (!!res.CompanyList) {
companyList = [];
for (const company of res.CompanyList) {
companyList.push({
companyCode: company.COMPANY_CODE,
companyName: company.COMPANY_NAME,
companyDomain: company.COMPANY_DOMAIN,
companyConfAuthYn: company.COMPANY_CONF_AUTH,
ucapUseYn: company.UCAP_USE_YN,
companyTimerChatAuthYn: company.COMPANY_TIMER_CHAT_AUTH
});
}
}
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
companyList
} as CompanyListResponse;
};

View File

@ -1,5 +1,10 @@
import { DeviceType, PushType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface TokenUpdateRequest extends APIRequest {
userSeq: string;
@ -11,3 +16,21 @@ export interface TokenUpdateRequest extends APIRequest {
// tslint:disable-next-line: no-empty-interface
export interface TokenUpdateResponse extends APIResponse {}
export const encodeTokenUpdate: APIEncoder<TokenUpdateRequest> = (
req: TokenUpdateRequest
) => {
return {
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_mobile_pid: req.mobilePid,
p_push_type: req.pushType
};
};
export const decodeTokenUpdate: APIDecoder<TokenUpdateResponse> = (
res: any
) => {
return {} as TokenUpdateResponse;
};

View File

@ -1,5 +1,10 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder
} from '@ucap-webmessenger/api';
export interface UrlInfoRequest extends APIRequest {
deviceType: DeviceType;
@ -19,3 +24,30 @@ export interface UrlInfoResponse extends APIResponse {
uprDownloadUrl?: string;
synapViewUrl?: string;
}
export const encodeUrlInfo: APIEncoder<UrlInfoRequest> = (
req: UrlInfoRequest
) => {
return {
p_device_type: req.deviceType
};
};
export const decodeUrlInfo: APIDecoder<UrlInfoResponse> = (res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
portCheckUrl: res.PortCheckURL,
messageUrl: res.MsgURL,
messageUrl2: res.MsgURL2,
passwordUrl: res.PasswordURL,
planUrl: res.PlanURL,
planUrl2: res.PlanURL2,
vocUrl: res.VocURL,
confUrl: res.ConfURL,
uprApiUrl: res.UprApiURL,
uprSvcUrl: res.UprSvcURL,
uprDownloadUrl: res.UprDownloadURL,
synapViewUrl: res.SynapViewURL
} as UrlInfoResponse;
};

View File

@ -8,18 +8,28 @@ import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config';
import {
CheckUserInfoExRequest,
CheckUserInfoExResponse
CheckUserInfoExResponse,
encodeCheckUserInfoEx,
decodeCheckUserInfoEx
} from '../models/check-user-info-ex';
import {
CompanyListRequest,
CompanyListResponse,
Company
encodeCompanyList,
decodeCompanyList
} from '../models/company-list';
import {
TokenUpdateRequest,
TokenUpdateResponse
TokenUpdateResponse,
encodeTokenUpdate,
decodeTokenUpdate
} from '../models/token-update';
import { UrlInfoResponse, UrlInfoRequest } from '../models/url-info';
import {
UrlInfoResponse,
UrlInfoRequest,
encodeUrlInfo,
decodeUrlInfo
} from '../models/url-info';
@Injectable({
providedIn: 'root'
@ -38,22 +48,10 @@ export class ExternalApiService {
this.moduleConfig.urls.checkUserInfoEx,
{},
{
params: {
p_user_id: req.userId,
p_comp_code: req.companyCode,
p_user_session: req.userSession
}
params: encodeCheckUserInfoEx(req)
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
userId: res.UserID
} as CheckUserInfoExResponse;
})
);
.pipe(map(res => decodeCheckUserInfoEx(res)));
}
public companyList(req: CompanyListRequest): Observable<CompanyListResponse> {
@ -62,39 +60,10 @@ export class ExternalApiService {
this.moduleConfig.urls.companyList,
{},
{
params: {
p_user_seq: req.userSeq,
p_app_type: req.appType,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_code: req.companyGroupCode
}
params: encodeCompanyList(req)
}
)
.pipe(
map(res => {
let companyList: Company[] | undefined;
if (!!res.CompanyList) {
companyList = [];
for (const company of res.CompanyList) {
companyList.push({
companyCode: company.COMPANY_CODE,
companyName: company.COMPANY_NAME,
companyDomain: company.COMPANY_DOMAIN,
companyConfAuthYn: company.COMPANY_CONF_AUTH,
ucapUseYn: company.UCAP_USE_YN,
companyTimerChatAuthYn: company.COMPANY_TIMER_CHAT_AUTH
});
}
}
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
companyList
} as CompanyListResponse;
})
);
.pipe(map(res => decodeCompanyList(res)));
}
public tokenUpdate(req: TokenUpdateRequest): Observable<TokenUpdateResponse> {
@ -103,20 +72,10 @@ export class ExternalApiService {
this.moduleConfig.urls.tokenUpdate,
{},
{
params: {
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_mobile_pid: req.mobilePid,
p_push_type: req.pushType
}
params: encodeTokenUpdate(req)
}
)
.pipe(
map(res => {
return {} as TokenUpdateResponse;
})
);
.pipe(map(res => decodeTokenUpdate(res)));
}
public urlInfo(req: UrlInfoRequest): Observable<UrlInfoResponse> {
@ -125,30 +84,9 @@ export class ExternalApiService {
this.moduleConfig.urls.urlInfo,
{},
{
params: {
p_device_type: req.deviceType
}
params: encodeUrlInfo(req)
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
portCheckUrl: res.PortCheckURL,
messageUrl: res.MsgURL,
messageUrl2: res.MsgURL2,
passwordUrl: res.PasswordURL,
planUrl: res.PlanURL,
planUrl2: res.PlanURL2,
vocUrl: res.VocURL,
confUrl: res.ConfURL,
uprApiUrl: res.UprApiURL,
uprSvcUrl: res.UprSvcURL,
uprDownloadUrl: res.UprDownloadURL,
synapViewUrl: res.SynapViewURL
} as UrlInfoResponse;
})
);
.pipe(map(res => decodeUrlInfo(res)));
}
}

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
export interface UpdateInfoRequest extends APIRequest {
deviceType: DeviceType;
@ -11,3 +17,24 @@ export interface UpdateInfoResponse extends APIResponse {
launcherAppVersion?: string;
launcherInstallUrl?: string;
}
const updateInfoEncodeMap = {
deviceType: 'p_device_type'
};
export const encodeUpdateInfo: APIEncoder<UpdateInfoRequest> = (
req: UpdateInfoRequest
) => {
return ParameterUtil.encode(updateInfoEncodeMap, req);
};
export const decodeUpdateInfo: APIDecoder<UpdateInfoResponse> = (res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as UpdateInfoResponse;
};

View File

@ -1,5 +1,11 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
ParameterUtil
} from '@ucap-webmessenger/api';
import { SyncMode } from '../types/sync-mode.type';
export interface VersionInfo2Request extends APIRequest {
@ -27,3 +33,41 @@ export interface VersionInfo2Response extends APIResponse {
launcherAppVersion?: string;
launcherInstallUrl?: string;
}
const versionInfo2EncodeMap = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
companyGroupType: 'p_comp_group_type',
companyCode: 'p_comp_code',
loginId: 'p_login_id'
};
export const encodeVersionInfo2: APIEncoder<VersionInfo2Request> = (
req: VersionInfo2Request
) => {
return ParameterUtil.encode(versionInfo2EncodeMap, req);
};
export const decodeVersionInfo2: APIDecoder<VersionInfo2Response> = (
res: any
) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
authIp: res.AuthIP === 'Y' ? true : false,
downloadUrl: res.DownloadURL,
fileAllowSize: Number(res.FileAllowSize),
fileTerm: Number(res.FileTerm),
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL,
profileRoot: res.ProfileRoot,
profileUploadUrl: res.ProfileUploadURL,
protocolCode: Number(res.ProtocolCD),
serverIp: res.ServerIP,
syncMode: res.SyncMode as SyncMode,
uploadUrl: res.UploadURL
} as VersionInfo2Response;
};

View File

@ -7,25 +7,17 @@ import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token';
import {
VersionInfo2Request,
VersionInfo2Response
VersionInfo2Response,
encodeVersionInfo2,
decodeVersionInfo2
} from '../models/version-info2';
import { UpdateInfoRequest, UpdateInfoResponse } from '../models/update-info';
import {
UpdateInfoRequest,
UpdateInfoResponse,
encodeUpdateInfo,
decodeUpdateInfo
} from '../models/update-info';
import { ModuleConfig } from '../types/module-config';
import { ParameterUtil } from '@ucap-webmessenger/api';
import { SyncMode } from '../types/sync-mode.type';
const versionInfo2Parameters = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
companyGroupType: 'p_comp_group_type',
companyCode: 'p_comp_code',
loginId: 'p_login_id'
};
const updateInfoParameters = {
deviceType: 'p_device_type'
};
@Injectable({
providedIn: 'root'
@ -44,31 +36,10 @@ export class PublicApiService {
this.moduleConfig.urls.versionInfo2,
{},
{
params: ParameterUtil.make(versionInfo2Parameters, req)
params: encodeVersionInfo2(req)
}
)
.pipe(
map((res: any) => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
authIp: res.AuthIP === 'Y' ? true : false,
downloadUrl: res.DownloadURL,
fileAllowSize: Number(res.FileAllowSize),
fileTerm: Number(res.FileTerm),
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL,
profileRoot: res.ProfileRoot,
profileUploadUrl: res.ProfileUploadURL,
protocolCode: Number(res.ProtocolCD),
serverIp: res.ServerIP,
syncMode: res.SyncMode as SyncMode,
uploadUrl: res.UploadURL
} as VersionInfo2Response;
})
);
.pipe(map((res: any) => decodeVersionInfo2(res)));
}
public updateInfo(req: UpdateInfoRequest): Observable<UpdateInfoResponse> {
@ -77,20 +48,9 @@ export class PublicApiService {
this.moduleConfig.urls.updateInfo,
{},
{
params: ParameterUtil.make(updateInfoParameters, req)
params: encodeUpdateInfo(req)
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as UpdateInfoResponse;
})
);
.pipe(map(res => decodeUpdateInfo(res)));
}
}

View File

@ -1,3 +1,5 @@
import { HttpParams } from '@angular/common/http';
import { StatusCode } from '../types/status-code.type';
export interface APIRequest {
@ -9,3 +11,13 @@ export interface APIResponse {
statusCode: StatusCode;
errorMessage: string;
}
export type APIEncoder<REQ> = (
req: REQ
) =>
| HttpParams
| {
[param: string]: string | string[];
};
export type APIDecoder<RES> = (res: any) => RES;

View File

@ -3,7 +3,7 @@ export type Parameter = {
} | null;
export class ParameterUtil {
public static make(parameterMap: {}, param: {}): Parameter {
public static encode(parameterMap: {}, param: {}): Parameter {
const parameter: Parameter = {};
Object.keys(parameterMap).map(key => {

View File

@ -9,7 +9,8 @@ import {
SVC_TYPE_LOGOUT,
SSVC_TYPE_LOGOUT_RES,
SSVC_TYPE_LOGOUT_REMOTE_NOTI,
AuthenticationProtocolService
decodeLogout,
decodeLogoutRemoteNotification
} from '@ucap-webmessenger/protocol-authentication';
import * as AuthenticationStore from '../store/account/authentication';
@ -18,7 +19,6 @@ import * as AuthenticationStore from '../store/account/authentication';
export class AppNotificationService {
constructor(
private protocolService: ProtocolService,
private authenticationProtocolService: AuthenticationProtocolService,
private store: Store<any>
) {}
@ -31,9 +31,7 @@ export class AppNotificationService {
message.subServiceType === SSVC_TYPE_LOGOUT_RES
),
tap(message => {
const logoutRes = this.authenticationProtocolService.decodeLogoutResponse(
message
);
const logoutRes = decodeLogout(message);
console.log('logoutRes', logoutRes);
this.store.dispatch(AuthenticationStore.logout());
})
@ -48,9 +46,7 @@ export class AppNotificationService {
message.subServiceType === SSVC_TYPE_LOGOUT_REMOTE_NOTI
),
tap(message => {
const logoutRemoteNoti = this.authenticationProtocolService.decodeLogoutRemoteNotification(
message
);
const logoutRemoteNoti = decodeLogoutRemoteNotification(message);
this.store.dispatch(AuthenticationStore.logout());
})
)

View File

@ -1,3 +1,5 @@
import { ParameterUtil, APIEncoder, APIDecoder } from '@ucap-webmessenger/api';
import { PIRequest, PIResponse } from './pi';
export interface Login2Request extends PIRequest {
@ -15,3 +17,26 @@ export interface Login2Response extends PIResponse {
userName: string;
userSeq: number;
}
const login2EncodeMap = {
companyCode: 'companyCd',
loginId: 'loginId',
loginPw: 'loginPw'
};
export const encodeLogin2: APIEncoder<Login2Request> = (req: Login2Request) => {
return ParameterUtil.encode(login2EncodeMap, req);
};
export const decodeLogin2: APIDecoder<Login2Response> = (res: any) => {
return {
status: res.STATUS,
version: res.VER,
passwordHc: res.PWD_HC,
personalInfoAgreeYn: res.PER_INFO_AGREE_YN,
companyCode: res.COMPANY_CODE,
userId: res.USER_ID,
userName: res.USER_NAME,
userSeq: res.USER_SEQ
} as Login2Response;
};

View File

@ -6,7 +6,12 @@ import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config';
import { Login2Request, Login2Response } from '../models/login2';
import {
Login2Request,
Login2Response,
encodeLogin2,
decodeLogin2
} from '../models/login2';
@Injectable({
providedIn: 'root'
@ -23,26 +28,9 @@ export class PiService {
this.moduleConfig.urls.login2,
{},
{
params: {
companyCd: req.companyCode,
loginId: req.loginId,
loginPw: req.loginPw
}
params: encodeLogin2(req)
}
)
.pipe(
map(res => {
return {
status: res.STATUS,
version: res.VER,
passwordHc: res.PWD_HC,
personalInfoAgreeYn: res.PER_INFO_AGREE_YN,
companyCode: res.COMPANY_CODE,
userId: res.USER_ID,
userName: res.USER_NAME,
userSeq: res.USER_SEQ
} as Login2Response;
})
);
.pipe(map(res => decodeLogin2(res)));
}
}

View File

@ -1,5 +1,13 @@
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol';
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
import { SSOMode } from '../types/sso-mode';
import { RoleCode } from '../types/role-code';
@ -79,3 +87,79 @@ export interface LoginResponse extends ProtocolResponse {
permissionsForViewSchedule: string;
havePermissionsForDevice: boolean;
}
export const encodeLogin: ProtocolEncoder<LoginRequest> = (
req: LoginRequest
) => {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.loginId },
{ type: PacketBodyValue.String, value: req.loginPw },
{ type: PacketBodyValue.String, value: req.deviceType },
{ type: PacketBodyValue.String, value: req.deviceId },
{ type: PacketBodyValue.String, value: req.token },
{ type: PacketBodyValue.String, value: req.localeCode },
{ type: PacketBodyValue.String, value: req.pushId },
{ type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType },
{ type: PacketBodyValue.String, value: req.clientVersion },
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.ip },
{ type: PacketBodyValue.String, value: req.hostName },
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 },
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
{ type: PacketBodyValue.String, value: req.productId },
{ type: PacketBodyValue.String, value: req.productName }
);
if (req.encriptionData) {
bodyList.push(
{ type: PacketBodyValue.String, value: req.encriptionData },
{ type: PacketBodyValue.String, value: req.accessToken }
);
}
return bodyList;
};
export const decodeLogin: ProtocolDecoder<LoginResponse> = (
message: ProtocolMessage
) => {
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;
};

View File

@ -0,0 +1,52 @@
import { DeviceType } from '@ucap-webmessenger/core';
import {
ProtocolRequest,
ProtocolResponse,
ProtocolNotification,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage,
PacketBodyValue
} from '@ucap-webmessenger/protocol';
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;
}
export const encodeLogoutRemote: ProtocolEncoder<LogoutRemoteRequest> = (
req: LogoutRemoteRequest
) => {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.targetDeviceType },
{ type: PacketBodyValue.String, value: req.requestDeviceType }
);
return bodyList;
};
export const decodeLogoutRemote: ProtocolDecoder<LogoutRemoteResponse> = (
message: ProtocolMessage
) => {
return {
targetDeviceType: message.bodyList[0],
resultCode: message.bodyList[1]
} as LogoutRemoteResponse;
};
export const decodeLogoutRemoteNotification: ProtocolDecoder<
LogoutRemoteNotification
> = (message: ProtocolMessage) => {
return { requestDeviceType: message.bodyList[0] } as LogoutRemoteNotification;
};

View File

@ -1,8 +1,10 @@
import { DeviceType } from '@ucap-webmessenger/core';
import {
ProtocolRequest,
ProtocolResponse,
ProtocolNotification
ProtocolEncoder,
ProtocolDecoder,
ProtocolMessage,
PacketBody
} from '@ucap-webmessenger/protocol';
// tslint:disable-next-line: no-empty-interface
@ -12,15 +14,16 @@ export interface LogoutResponse extends ProtocolResponse {
reasonCode?: number;
}
export interface LogoutRemoteRequest extends ProtocolRequest {
targetDeviceType?: DeviceType;
requestDeviceType?: DeviceType;
}
export interface LogoutRemoteResponse extends ProtocolResponse {
targetDeviceType?: DeviceType;
resultCode?: number;
}
export const encodeLogout: ProtocolEncoder<LogoutRequest> = (
req: LogoutRequest
) => {
const bodyList: PacketBody[] = [];
export interface LogoutRemoteNotification extends ProtocolNotification {
requestDeviceType?: DeviceType;
}
return bodyList;
};
export const decodeLogout: ProtocolDecoder<LogoutResponse> = (
message: ProtocolMessage
) => {
return { reasonCode: message.bodyList[0] } as LogoutResponse;
};

View File

@ -3,13 +3,13 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol';
import {
ProtocolService,
PacketBody,
PacketBodyValue,
ServerMessage
} from '@ucap-webmessenger/protocol';
import { LoginRequest, LoginResponse } from '../models/login';
LoginRequest,
LoginResponse,
encodeLogin,
decodeLogin
} from '../models/login';
import {
SVC_TYPE_LOGIN,
SSVC_TYPE_LOGIN_REQ,
@ -17,14 +17,18 @@ import {
SSVC_TYPE_LOGOUT_REQ,
SSVC_TYPE_LOGOUT_REMOTE_REQ
} from '../types/service';
import { RoleCode } from '../types/role-code';
import {
LogoutRequest,
LogoutResponse,
LogoutRemoteRequest,
LogoutRemoteResponse,
LogoutRemoteNotification
encodeLogout,
decodeLogout
} from '../models/logout';
import {
encodeLogoutRemote,
decodeLogoutRemote,
LogoutRemoteRequest,
LogoutRemoteResponse
} from '../models/logout-remote';
@Injectable({
providedIn: 'root'
@ -33,132 +37,26 @@ export class AuthenticationProtocolService {
constructor(private protocolService: ProtocolService) {}
public login(req: LoginRequest): Observable<LoginResponse> {
const bodyList: PacketBody[] = [];
bodyList.push(
{ type: PacketBodyValue.String, value: req.loginId },
{ type: PacketBodyValue.String, value: req.loginPw },
{ type: PacketBodyValue.String, value: req.deviceType },
{ type: PacketBodyValue.String, value: req.deviceId },
{ type: PacketBodyValue.String, value: req.token },
{ type: PacketBodyValue.String, value: req.localeCode },
{ type: PacketBodyValue.String, value: req.pushId },
{ type: PacketBodyValue.String, value: req.companyCode },
{ type: PacketBodyValue.Integer, value: req.passwordEncodingType },
{ type: PacketBodyValue.String, value: req.clientVersion },
{ type: PacketBodyValue.String, value: req.reconnect ? 'Y' : 'N' },
{ type: PacketBodyValue.String, value: req.ip },
{ type: PacketBodyValue.String, value: req.hostName },
{ type: PacketBodyValue.Integer, value: req.encriptionData ? 2 : 1 },
{ type: PacketBodyValue.String, value: req.userSpecificInformation },
{ type: PacketBodyValue.String, value: req.productId },
{ type: PacketBodyValue.String, value: req.productName }
);
if (req.encriptionData) {
bodyList.push(
{ type: PacketBodyValue.String, value: req.encriptionData },
{ type: PacketBodyValue.String, value: req.accessToken }
);
}
return this.protocolService
.call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...bodyList)
.pipe(
map(res => {
return this.decodeLoginResponse(res);
})
);
}
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;
.call(SVC_TYPE_LOGIN, SSVC_TYPE_LOGIN_REQ, ...encodeLogin(req))
.pipe(map(res => decodeLogin(res)));
}
public logout(req: LogoutRequest): Observable<LogoutResponse> {
return this.protocolService
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ)
.pipe(
map(res => {
return this.decodeLogoutResponse(res);
})
);
}
public decodeLogoutResponse(message: ServerMessage): LogoutResponse {
return {
reasonCode: message.bodyList[0]
} as LogoutResponse;
.call(SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_REQ, ...encodeLogout(req))
.pipe(map(res => decodeLogout(res)));
}
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;
.call(
SVC_TYPE_LOGOUT,
SSVC_TYPE_LOGOUT_REMOTE_REQ,
...encodeLogoutRemote(req)
)
.pipe(map(res => decodeLogoutRemote(res)));
}
}

View File

@ -5,6 +5,7 @@
export * from './lib/models/fmc';
export * from './lib/models/login';
export * from './lib/models/logout';
export * from './lib/models/logout-remote';
export * from './lib/services/authentication-protocol.service';

View File

@ -1,8 +1,26 @@
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
import { ProtocolRequest, ProtocolResponse } from '@ucap-webmessenger/protocol';
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
// tslint:disable-next-line: no-empty-interface
export interface ConnRequest extends ProtocolRequest {}
// tslint:disable-next-line: no-empty-interface
export interface ConnResponse extends ProtocolResponse {}
export const encodeConn: ProtocolEncoder<ConnRequest> = (req: ConnRequest) => {
const bodyList: PacketBody[] = [];
return bodyList;
};
export const decodeConn: ProtocolDecoder<ConnResponse> = (
message: ProtocolMessage
) => {
return {} as ConnResponse;
};

View File

@ -5,7 +5,12 @@ import { map } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol';
import { ConnResponse, ConnRequest } from '../models/conn';
import {
ConnResponse,
ConnRequest,
encodeConn,
decodeConn
} from '../models/conn';
import { SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ } from '../types/service';
@Injectable({
@ -15,10 +20,8 @@ export class InnerProtocolService {
constructor(private protocolService: ProtocolService) {}
public conn(req: ConnRequest): Observable<ConnResponse> {
return this.protocolService.call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ).pipe(
map(res => {
return {} as ConnResponse;
})
);
return this.protocolService
.call(SVC_TYPE_INNER, SSVC_TYPE_CONN_REQ, ...encodeConn(req))
.pipe(map(res => decodeConn(res)));
}
}

View File

@ -1,3 +1,5 @@
import { PacketBody } from './packet';
export interface ProtocolRequest {
_id?: string;
}
@ -8,3 +10,14 @@ export interface ProtocolResponse {
// tslint:disable-next-line: no-empty-interface
export interface ProtocolNotification {}
export interface ProtocolMessage {
serviceType: number;
subServiceType: number;
senderSeq: number;
bodyList: any[];
}
export type ProtocolEncoder<REQ> = (req: REQ) => PacketBody[];
export type ProtocolDecoder<RES> = (message: ProtocolMessage) => RES;

View File

@ -20,16 +20,10 @@ import {
} from '../types/packet-body-divider';
import { PacketBodyValue } from '../types/packet-body-value.type';
import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service';
export interface ServerMessage {
serviceType: number;
subServiceType: number;
senderSeq: number;
bodyList: any[];
}
import { ProtocolMessage } from '../models/protocol';
interface RequestState {
subject: Subject<ServerMessage>;
subject: Subject<ProtocolMessage>;
request: {
serviceType: number;
subServiceType: number;
@ -48,8 +42,8 @@ export class ProtocolService {
private socket$: Observable<GetWebSocketResponses<any>>;
private messages$: Observable<any>;
private messagesSubscription: Subscription | null = null;
private serverMessageSubject: Subject<ServerMessage> | null = null;
private serverMessage$: Observable<ServerMessage> | null = null;
private serverMessageSubject: Subject<ProtocolMessage> | null = null;
private serverMessage$: Observable<ProtocolMessage> | null = null;
constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) {
this.pendingRequests = new Map();
@ -131,7 +125,7 @@ export class ProtocolService {
this.messagesSubscription.unsubscribe();
}
public get serverMessage(): Observable<ServerMessage> {
public get serverMessage(): Observable<ProtocolMessage> {
return this.serverMessage$;
}
@ -139,7 +133,7 @@ export class ProtocolService {
serviceType: number | null,
subServiceType: number | null,
...bodyList: PacketBody[]
): Observable<ServerMessage> {
): Observable<ProtocolMessage> {
return this.sendInternal(true, serviceType, subServiceType, bodyList);
}
@ -156,9 +150,9 @@ export class ProtocolService {
serviceType: number,
subServiceType: number,
bodyList: PacketBody[]
): Observable<ServerMessage> | undefined {
): Observable<ProtocolMessage> | undefined {
let packet: string;
let responseSubject: Subject<ServerMessage> | null = null;
let responseSubject: Subject<ProtocolMessage> | null = null;
if (hasResponse) {
const requestId = this.requestId;
@ -168,7 +162,7 @@ export class ProtocolService {
{ type: PacketBodyValue.RequestId, value: requestId }
]);
responseSubject = new Subject<ServerMessage>();
responseSubject = new Subject<ProtocolMessage>();
this.pendingRequests.set(requestId, {
subject: responseSubject,
request: { serviceType, subServiceType, bodyList }
@ -195,7 +189,7 @@ export class ProtocolService {
private decodePacket(
arg: string[]
): { requestId: number; message: ServerMessage } | null {
): { requestId: number; message: ProtocolMessage } | null {
const cmdArg = arg[0].split(PacketBodyValueDivider);
if (2 > cmdArg.length) {
// OnError(3);