add protocol BUDDY all
This commit is contained in:
parent
88c49bc900
commit
1c848e6e1c
|
@ -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 BuddyAddRequest extends ProtocolRequest {
|
||||
// 0n. 사용자SEQ(n)...
|
||||
userSeqs: number[];
|
||||
}
|
||||
|
||||
export interface BuddyAddResponse extends ProtocolResponse {
|
||||
// 0n. 사용자SEQ(n)...
|
||||
userSeqs: number[];
|
||||
}
|
||||
|
||||
export const encodeBuddyAdd: ProtocolEncoder<BuddyAddRequest> = (
|
||||
req: BuddyAddRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
for (const userSeq of req.userSeqs) {
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
|
||||
}
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeBuddyAdd: ProtocolDecoder<BuddyAddResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
const userSeqArray: number[] = [...message.bodyList];
|
||||
return {
|
||||
userSeqs: userSeqArray
|
||||
} as BuddyAddResponse;
|
||||
};
|
|
@ -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 BuddyDelRequest extends ProtocolRequest {
|
||||
// 0n. 사용자SEQ(n)...
|
||||
userSeqs: number[];
|
||||
}
|
||||
|
||||
export interface BuddyDelResponse extends ProtocolResponse {
|
||||
// 0n. 사용자SEQ(n)...
|
||||
userSeqs: number[];
|
||||
}
|
||||
|
||||
export const encodeBuddyDel: ProtocolEncoder<BuddyDelRequest> = (
|
||||
req: BuddyDelRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
for (const userSeq of req.userSeqs) {
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
|
||||
}
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeBuddyDel: ProtocolDecoder<BuddyDelResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
const userSeqArray: number[] = [...message.bodyList];
|
||||
return {
|
||||
userSeqs: userSeqArray
|
||||
} as BuddyDelResponse;
|
||||
};
|
|
@ -0,0 +1,47 @@
|
|||
import { DeviceType, LocaleCode } from '@ucap-webmessenger/core';
|
||||
import {
|
||||
ProtocolRequest,
|
||||
ProtocolResponse,
|
||||
ProtocolEncoder,
|
||||
PacketBody,
|
||||
PacketBodyValue,
|
||||
ProtocolDecoder,
|
||||
ProtocolMessage
|
||||
} from '@ucap-webmessenger/protocol';
|
||||
|
||||
export interface BuddyUpdateRequest extends ProtocolRequest {
|
||||
// 0. 사용자SEQ(n)
|
||||
userSeq: number;
|
||||
// 1. 즐겨찾기여부(y)
|
||||
favorit: boolean;
|
||||
}
|
||||
|
||||
export interface BuddyUpdateResponse extends ProtocolResponse {
|
||||
// 0. 사용자SEQ(n)
|
||||
userSeq: number;
|
||||
// 1. 즐겨찾기여부(y)
|
||||
favorit: boolean;
|
||||
}
|
||||
|
||||
export const encodeBuddyUpdate: ProtocolEncoder<BuddyUpdateRequest> = (
|
||||
req: BuddyUpdateRequest
|
||||
) => {
|
||||
const bodyList: PacketBody[] = [];
|
||||
|
||||
bodyList.push({ type: PacketBodyValue.Integer, value: req.userSeq });
|
||||
bodyList.push({
|
||||
type: PacketBodyValue.String,
|
||||
value: req.favorit ? 'Y' : 'N'
|
||||
});
|
||||
|
||||
return bodyList;
|
||||
};
|
||||
|
||||
export const decodeBuddyUpdate: ProtocolDecoder<BuddyUpdateResponse> = (
|
||||
message: ProtocolMessage
|
||||
) => {
|
||||
return {
|
||||
userSeq: message.bodyList[0],
|
||||
favorit: message.bodyList[1] === 'Y' ? true : false
|
||||
} as BuddyUpdateResponse;
|
||||
};
|
|
@ -1,8 +1,54 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
||||
|
||||
import {
|
||||
SVC_TYPE_BUDDY,
|
||||
SSVC_TYPE_BUDDY_ADD_REQ,
|
||||
SSVC_TYPE_BUDDY_DEL_REQ,
|
||||
SSVC_TYPE_BUDDY_UPD_REQ
|
||||
} from '../types/service';
|
||||
|
||||
import {
|
||||
BuddyAddRequest,
|
||||
encodeBuddyAdd,
|
||||
decodeBuddyAdd
|
||||
} from '../models/buddy-add';
|
||||
import {
|
||||
BuddyDelRequest,
|
||||
encodeBuddyDel,
|
||||
decodeBuddyDel
|
||||
} from '../models/buddy-del';
|
||||
import {
|
||||
BuddyUpdateRequest,
|
||||
decodeBuddyUpdate,
|
||||
encodeBuddyUpdate
|
||||
} from '../models/buddy-update';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BuddyProtocolService {
|
||||
constructor() {}
|
||||
constructor(private protocolService: ProtocolService) {}
|
||||
|
||||
public buddyAdd(req: BuddyAddRequest): Observable<BuddyAddRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeBuddyAdd(req))
|
||||
.pipe(map(res => decodeBuddyAdd(res)));
|
||||
}
|
||||
|
||||
public buddyDel(req: BuddyDelRequest): Observable<BuddyDelRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeBuddyDel(req))
|
||||
.pipe(map(res => decodeBuddyDel(res)));
|
||||
}
|
||||
|
||||
public buddyUpdate(req: BuddyUpdateRequest): Observable<BuddyUpdateRequest> {
|
||||
return this.protocolService
|
||||
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeBuddyUpdate(req))
|
||||
.pipe(map(res => decodeBuddyUpdate(res)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
export const SVC_TYPE_BUDDY = 4; // 동료 관리
|
||||
export const SSVC_TYPE_BUDDY_ADD_REQ = 1; // 동료추가
|
||||
export const SSVC_TYPE_BUDDY_ADD_RES = 2;
|
||||
export const SSVC_TYPE_BUDDY_DEL_REQ = 11; // 동료삭제
|
||||
export const SSVC_TYPE_BUDDY_DEL_RES = 12;
|
||||
export const SSVC_TYPE_BUDDY_UPD_REQ = 21; // 동료변경
|
||||
export const SSVC_TYPE_BUDDY_UPD_RES = 22;
|
Loading…
Reference in New Issue
Block a user