added protocol > INFO
This commit is contained in:
parent
84aaa4e901
commit
f88d16de8b
|
@ -0,0 +1,58 @@
|
|||
import { DeviceType, LocaleCode, StatusCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage,
|
||||
ProtocolNotification,
|
||||
BodyStringDivider
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
import { UserInfoUpdateType } from '../types/user-info-update.type';
|
||||
import { StatusInfo } from '@ucap-webmessenger/protocol-status';
|
||||
|
||||
export interface StatusRequest extends ProtocolRequest {
|
||||
// 사용자SEQ(n)...
|
||||
userSeqs: number[];
|
||||
}
|
||||
|
||||
export interface StatusResponse extends ProtocolResponse {
|
||||
// {상태정보}...
|
||||
statusInfos: StatusInfo[];
|
||||
}
|
||||
|
||||
export const encodeStatus: ProtocolEncoder<StatusRequest> = (
|
||||
req: StatusRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
req.userSeqs.forEach(userSeq => {
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
|
||||
});
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeStatus: ProtocolDecoder<StatusResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
const statusInfos: StatusInfo[] = [];
|
||||
message.bodyList.forEach(statusInfo => {
|
||||
const info = statusInfo.split(BodyStringDivider);
|
||||
let idx = 0;
|
||||
statusInfos.push({
|
||||
userSeq: info[idx],
|
||||
pcStatus: info[idx++] as StatusCode,
|
||||
phoneStatus: info[idx++] as StatusCode,
|
||||
mobileStatus: info[idx++] as StatusCode,
|
||||
conferenceStatus: info[idx++] as StatusCode,
|
||||
statusMessage: info[idx++],
|
||||
mobileConferenceStatus: info[idx++] as StatusCode,
|
||||
imessengerStatus: info[idx++] as StatusCode
|
||||
});
|
||||
});
|
||||
return {
|
||||
statusInfos
|
||||
} as StatusResponse;
|
||||
};
|
|
@ -0,0 +1,50 @@
|
|||
import { DeviceType, LocaleCode, CallerType } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage,
|
||||
ProtocolNotification
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
import { UserInfoUpdateType } from '../types/user-info-update.type';
|
||||
|
||||
export interface UserOptionResponse extends ProtocolResponse {
|
||||
// 타입(s)
|
||||
type: CallerType;
|
||||
}
|
||||
|
||||
export const decodeUserOption: ProtocolDecoder<UserOptionResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return { type: message.bodyList[0] as CallerType } as UserOptionResponse;
|
||||
};
|
||||
|
||||
export interface UserOptionUpdateRequest extends ProtocolRequest {
|
||||
// 타입(s)
|
||||
type: CallerType;
|
||||
}
|
||||
|
||||
export interface UserOptionUpdateResponse extends ProtocolResponse {
|
||||
// 타입(s)
|
||||
type: CallerType;
|
||||
}
|
||||
|
||||
export const encodeUserOptionUpdate: ProtocolEncoder<
|
||||
UserOptionUpdateRequest
|
||||
> = (req: UserOptionUpdateRequest) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push({ type: PacketBodyValue.String, value: req.type });
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeUserOptionUpdate: ProtocolDecoder<
|
||||
UserOptionUpdateResponse
|
||||
> = (message: ProtocolMessage) => {
|
||||
return {
|
||||
type: message.bodyList[0] as CallerType
|
||||
} as UserOptionUpdateResponse;
|
||||
};
|
|
@ -0,0 +1,62 @@
|
|||
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage,
|
||||
ProtocolNotification
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
import { UserInfoUpdateType } from '../types/user-info-update.type';
|
||||
|
||||
export interface UserRequest extends ProtocolRequest {
|
||||
// 타입(s)
|
||||
type: UserInfoUpdateType;
|
||||
// 정보(s)
|
||||
info: string;
|
||||
}
|
||||
|
||||
export interface UserResponse extends ProtocolResponse {
|
||||
// 타입(s)
|
||||
type: UserInfoUpdateType;
|
||||
// 정보(s)
|
||||
info: string;
|
||||
}
|
||||
|
||||
export interface UserNotification extends ProtocolNotification {
|
||||
// 타입(s)
|
||||
type: UserInfoUpdateType;
|
||||
// 정보(s)
|
||||
info: string;
|
||||
}
|
||||
|
||||
export const encodeUser: ProtocolEncoder<UserRequest> = (req: UserRequest) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push(
|
||||
{ type: PacketBodyValue.String, value: req.type },
|
||||
{ type: PacketBodyValue.String, value: req.info }
|
||||
);
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeUser: ProtocolDecoder<UserResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return {
|
||||
type: message.bodyList[0] as UserInfoUpdateType,
|
||||
info: message.bodyList[1]
|
||||
} as UserResponse;
|
||||
};
|
||||
|
||||
export const decodeUserNotification: ProtocolDecoder<UserNotification> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return {
|
||||
type: message.bodyList[0] as UserInfoUpdateType,
|
||||
info: message.bodyList[1]
|
||||
} as UserNotification;
|
||||
};
|
|
@ -1,8 +1,82 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||
import {
|
||||
SVC_TYPE_INFO,
|
||||
SSVC_TYPE_INFO_USER_REQ,
|
||||
SSVC_TYPE_INFO_STATE_REQ,
|
||||
SSVC_TYPE_INFO_USER_OPTION_REQ,
|
||||
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ
|
||||
} from '../types/service';
|
||||
import {
|
||||
UserRequest,
|
||||
encodeUser,
|
||||
UserResponse,
|
||||
decodeUser
|
||||
} from '../models/user';
|
||||
import {
|
||||
StatusRequest,
|
||||
StatusResponse,
|
||||
encodeStatus,
|
||||
decodeStatus
|
||||
} from '../models/status';
|
||||
import {
|
||||
UserOptionResponse,
|
||||
decodeUserOption,
|
||||
UserOptionUpdateRequest,
|
||||
encodeUserOptionUpdate,
|
||||
UserOptionUpdateResponse,
|
||||
decodeUserOptionUpdate
|
||||
} from '../models/user-option';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class InfoProtocolService {
|
||||
constructor() {}
|
||||
constructor(private protocolService: ProtocolService) {}
|
||||
|
||||
public user(req: UserRequest): Observable<UserResponse> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_REQ, ...encodeUser(req))
|
||||
.pipe(
|
||||
take(1),
|
||||
map(res => decodeUser(res))
|
||||
);
|
||||
}
|
||||
|
||||
public status(req: StatusRequest): Observable<StatusResponse> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_STATE_REQ, ...encodeStatus(req))
|
||||
.pipe(
|
||||
take(1),
|
||||
map(res => decodeStatus(res))
|
||||
);
|
||||
}
|
||||
|
||||
public userOption(): Observable<UserOptionResponse> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_INFO, SSVC_TYPE_INFO_USER_OPTION_REQ)
|
||||
.pipe(
|
||||
take(1),
|
||||
map(res => decodeUserOption(res))
|
||||
);
|
||||
}
|
||||
|
||||
public userOptionUpdate(
|
||||
req: UserOptionUpdateRequest
|
||||
): Observable<UserOptionUpdateResponse> {
|
||||
return this.protocolService
|
||||
.call(
|
||||
SVC_TYPE_INFO,
|
||||
SSVC_TYPE_INFO_USER_OPTION_UPD_REQ,
|
||||
...encodeUserOptionUpdate(req)
|
||||
)
|
||||
.pipe(
|
||||
take(1),
|
||||
map(res => decodeUserOptionUpdate(res))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
export const SVC_TYPE_INFO = 30;
|
||||
export const SSVC_TYPE_INFO_USER_REQ = 1; // 사용자 정보 변경 요청
|
||||
export const SSVC_TYPE_INFO_USER_RES = 2;
|
||||
export const SSVC_TYPE_INFO_USER_NOTI = 3;
|
||||
export const SSVC_TYPE_INFO_STATE_REQ = 11; // 사용자 상태 정보 요청
|
||||
export const SSVC_TYPE_INFO_STATE_RES = 13; // 사용자 상태 정보 응답
|
||||
export const SSVC_TYPE_INFO_USER_OPTION_REQ = 21; // 사용자 환경 정보 요청
|
||||
export const SSVC_TYPE_INFO_USER_OPTION_RES = 22; // 사용자 환경 정보 응답
|
||||
export const SSVC_TYPE_INFO_USER_OPTION_UPD_REQ = 23; // 사용자 환경 정보 변경 요청
|
||||
export const SSVC_TYPE_INFO_USER_OPTION_UPD_RES = 24; // 사용자 환경 정보 변경 응답
|
||||
export const SSVC_TYPE_INFO_QUERY_SESSION_REQ = 41; // 세션 정보 요청
|
||||
export const SSVC_TYPE_INFO_QUERY_SESSION_RES = 42; // 세션 정보 응답
|
||||
export const SSVC_TYPE_INFO_BUDDY_NICKNAME_REQ = 51; // 동료 닉네임 변경 요청
|
||||
export const SSVC_TYPE_INFO_BUDDY_NICKNAME_RES = 52; // 동료 닉네임 변경 응답
|
|
@ -0,0 +1,13 @@
|
|||
export enum UserInfoUpdateType {
|
||||
// I: 프로필 이미지
|
||||
Image = 'I',
|
||||
// R: 인트로소개
|
||||
Intro = 'R',
|
||||
// T: 전화보이기여부
|
||||
TelephoneVisible = 'T'
|
||||
}
|
||||
|
||||
export enum TelephoneVisibleType {
|
||||
Show = 'Y',
|
||||
Hide = 'N'
|
||||
}
|
|
@ -2,6 +2,13 @@
|
|||
* Public API Surface of ucap-webmessenger-protocol-info
|
||||
*/
|
||||
|
||||
export * from './lib/models/status';
|
||||
export * from './lib/models/user-option';
|
||||
export * from './lib/models/user';
|
||||
|
||||
export * from './lib/services/info-protocol.service';
|
||||
|
||||
export * from './lib/types/service';
|
||||
export * from './lib/types/user-info-update.type';
|
||||
|
||||
export * from './lib/ucap-info-protocol.module';
|
||||
|
|
Loading…
Reference in New Issue
Block a user