add protocol GROUP all
This commit is contained in:
parent
e847133650
commit
5c1c0f30fc
|
@ -0,0 +1,41 @@
|
|||
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
|
||||
export interface GroupAddRequest extends ProtocolRequest {
|
||||
// 0. 동료그룹이름
|
||||
groupName: string;
|
||||
}
|
||||
|
||||
export interface GroupAddResponse extends ProtocolResponse {
|
||||
// 0: 동료그룹SEQ(n)
|
||||
groupSeq: number;
|
||||
// 1: 동료그룹이름(s)
|
||||
groupName: string;
|
||||
}
|
||||
|
||||
export const encodeGroupAdd: ProtocolEncoder<GroupAddRequest> = (
|
||||
req: GroupAddRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push({ type: PacketBodyValue.String, value: req.groupName });
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeGroupAdd: ProtocolDecoder<GroupAddResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return {
|
||||
groupSeq: message.bodyList[0],
|
||||
groupName: message.bodyList[1]
|
||||
} as GroupAddResponse;
|
||||
};
|
|
@ -0,0 +1,38 @@
|
|||
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
|
||||
export interface GroupDelRequest extends ProtocolRequest {
|
||||
// 0: 동료그룹SEQ(n)
|
||||
groupSeq: number;
|
||||
}
|
||||
|
||||
export interface GroupDelResponse extends ProtocolResponse {
|
||||
// 0: 동료그룹SEQ(n)
|
||||
groupSeq: number;
|
||||
}
|
||||
|
||||
export const encodeGroupDel: ProtocolEncoder<GroupDelRequest> = (
|
||||
req: GroupDelRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: req.groupSeq });
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeGroupDel: ProtocolDecoder<GroupDelResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return {
|
||||
groupSeq: message.bodyList[0]
|
||||
} as GroupDelResponse;
|
||||
};
|
|
@ -0,0 +1,91 @@
|
|||
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
|
||||
export interface GroupUpdateRequest extends ProtocolRequest {
|
||||
// 0: 동료그룹SEQ(n)
|
||||
groupSeq: number;
|
||||
// 1: 동료그룹이름(s)
|
||||
groupName: string;
|
||||
// 2n: 사용자SEQ(n)...
|
||||
userSeqs: [];
|
||||
}
|
||||
|
||||
export interface GroupUpdateResponse extends ProtocolResponse {
|
||||
// 0: 동료그룹SEQ(n)
|
||||
groupSeq: number;
|
||||
// 1: 동료그룹이름(s)
|
||||
groupName: string;
|
||||
// 2n: 사용자SEQ(n)...
|
||||
userSeqs: [];
|
||||
}
|
||||
|
||||
export const encodeGroupUpdate: ProtocolEncoder<GroupUpdateRequest> = (
|
||||
req: GroupUpdateRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push(
|
||||
{ type: PacketBodyValue.Integer, value: req.groupSeq },
|
||||
{ type: PacketBodyValue.String, value: req.groupName },
|
||||
{ type: PacketBodyValue.String, value: req.userSeqs.join() }
|
||||
);
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeGroupUpdate: ProtocolDecoder<GroupUpdateResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
let userSeqArray: Array<number> = [];
|
||||
if (message.bodyList.length > 2 && !message.bodyList[2].empty()) {
|
||||
userSeqArray = message.bodyList[2].split(',').map(v => Number(v));
|
||||
}
|
||||
|
||||
return {
|
||||
groupSeq: message.bodyList[0],
|
||||
groupName: message.bodyList[1],
|
||||
userSeqs: userSeqArray
|
||||
} as GroupUpdateResponse;
|
||||
};
|
||||
|
||||
export const encodeGroupUpdate2: ProtocolEncoder<GroupUpdateRequest> = (
|
||||
req: GroupUpdateRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push(
|
||||
{ type: PacketBodyValue.Integer, value: req.groupSeq },
|
||||
{ type: PacketBodyValue.String, value: req.groupName }
|
||||
);
|
||||
|
||||
if (req.userSeqs.length > 0) {
|
||||
req.userSeqs.forEach(userSeq => {
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
|
||||
});
|
||||
}
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeGroupUpdate2: ProtocolDecoder<GroupUpdateResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
let userSeqArray: Array<number> = [];
|
||||
if (message.bodyList.length > 2) {
|
||||
userSeqArray = message.bodyList.slice(2);
|
||||
}
|
||||
|
||||
return {
|
||||
groupSeq: message.bodyList[0],
|
||||
groupName: message.bodyList[1],
|
||||
userSeqs: userSeqArray
|
||||
} as GroupUpdateResponse;
|
||||
};
|
|
@ -1,8 +1,64 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||
import {
|
||||
GroupAddRequest,
|
||||
encodeGroupAdd,
|
||||
decodeGroupAdd
|
||||
} from '../models/group-add';
|
||||
import {
|
||||
SVC_TYPE_GROUP,
|
||||
SSVC_TYPE_GROUP_ADD_REQ,
|
||||
SSVC_TYPE_GROUP_DEL_REQ,
|
||||
SSVC_TYPE_GROUP_UPD_REQ,
|
||||
SSVC_TYPE_GROUP_UPD_REQ2
|
||||
} from '../types/service';
|
||||
import {
|
||||
GroupDelRequest,
|
||||
encodeGroupDel,
|
||||
decodeGroupDel
|
||||
} from '../models/group-del';
|
||||
import {
|
||||
GroupUpdateRequest,
|
||||
encodeGroupUpdate,
|
||||
decodeGroupUpdate,
|
||||
encodeGroupUpdate2,
|
||||
decodeGroupUpdate2
|
||||
} from '../models/group-update';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class GroupProtocolService {
|
||||
constructor() {}
|
||||
constructor(private protocolService: ProtocolService) {}
|
||||
|
||||
public groupAdd(req: GroupAddRequest): Observable<GroupAddRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req))
|
||||
.pipe(map(res => decodeGroupAdd(res)));
|
||||
}
|
||||
|
||||
public groupDel(req: GroupDelRequest): Observable<GroupDelRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req))
|
||||
.pipe(map(res => decodeGroupDel(res)));
|
||||
}
|
||||
|
||||
public groupUpdate(req: GroupUpdateRequest): Observable<GroupUpdateRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req))
|
||||
.pipe(map(res => decodeGroupUpdate(res)));
|
||||
}
|
||||
|
||||
public groupUpdate2(req: GroupUpdateRequest): Observable<GroupUpdateRequest> {
|
||||
return this.protocolService
|
||||
.call(
|
||||
SVC_TYPE_GROUP,
|
||||
SSVC_TYPE_GROUP_UPD_REQ2,
|
||||
...encodeGroupUpdate2(req)
|
||||
)
|
||||
.pipe(map(res => decodeGroupUpdate2(res)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
export const SVC_TYPE_GROUP = 5; // 동료 그룹 관리
|
||||
export const SSVC_TYPE_GROUP_ADD_REQ = 1; // 동료 그룹 추가
|
||||
export const SSVC_TYPE_GROUP_ADD_RES = 2;
|
||||
export const SSVC_TYPE_GROUP_DEL_REQ = 11; // 동료 그룹 삭제
|
||||
export const SSVC_TYPE_GROUP_DEL_RES = 12;
|
||||
export const SSVC_TYPE_GROUP_UPD_REQ = 21; // 동료 그룹 변경
|
||||
export const SSVC_TYPE_GROUP_UPD_RES = 22;
|
||||
export const SSVC_TYPE_GROUP_UPD_REQ2 = 23;
|
||||
export const SSVC_TYPE_GROUP_UPD_RES2 = 24;
|
Loading…
Reference in New Issue
Block a user