add protocol ROOM > OPEN all

This commit is contained in:
leejh 2019-09-23 14:38:22 +09:00
parent aaf3e2c743
commit a6b93f8be8
6 changed files with 350 additions and 1 deletions

View File

@ -0,0 +1,48 @@
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
export interface RoomOpenRequest extends ProtocolRequest {
// 0. 구분자
divCd: string;
// 1n. 초대자 userSeq(n)...
userSeqs: number[];
}
export interface RoomOpenResponse extends ProtocolResponse {
// 0. 구분자
divCd: string;
// 1. 대화방SEQ(s)
roomSeq: string;
// 2. 신규여부(y)
newRoom: boolean;
}
export const encodeRoomOpen: ProtocolEncoder<RoomOpenRequest> = (
req: RoomOpenRequest
) => {
const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
for (const userSeq of req.userSeqs) {
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
}
return bodyList;
};
export const decodeRoomOpen: ProtocolDecoder<RoomOpenResponse> = (
message: ProtocolMessage
) => {
return {
divCd: message.bodyList[0],
roomSeq: message.bodyList[1],
newRoom: message.bodyList[2] === 'Y' ? true : false
} as RoomOpenResponse;
};

View File

@ -0,0 +1,54 @@
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
export interface RoomOpen2Request extends ProtocolRequest {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2n. 초대자 userSeq(n)...
userSeqs: number[];
}
export interface RoomOpen2Response extends ProtocolResponse {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2. 대화방SEQ(s)
roomSeq: string;
// 3. 신규여부(y)
newRoom: boolean;
}
export const encodeRoomOpen2: ProtocolEncoder<RoomOpen2Request> = (
req: RoomOpen2Request
) => {
const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() });
for (const userSeq of req.userSeqs) {
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
}
return bodyList;
};
export const decodeRoomOpen2: ProtocolDecoder<RoomOpen2Response> = (
message: ProtocolMessage
) => {
return {
divCd: message.bodyList[0],
roomName: message.bodyList[1],
roomSeq: message.bodyList[2],
newRoom: message.bodyList[3] === 'Y' ? true : false
} as RoomOpen2Response;
};

View File

@ -0,0 +1,72 @@
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
export interface RoomOpen3Request extends ProtocolRequest {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2. 타이머대화방여부YN(s)
isTimerRoom: boolean;
// 3. 타이머시간(n)
timerRoomInterval: number;
// 4n. 초대자 userSeq(n)...
userSeqs: number[];
}
export interface RoomOpen3Response extends ProtocolResponse {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2. 대화방SEQ(s)
roomSeq: string;
// 3. 신규여부(y)
newRoom: boolean;
// 4. 타이머대화방여부YN(s)
isTimerRoom: boolean;
// 5. 타이머시간(n)
timerRoomInterval: number;
}
export const encodeRoomOpen3: ProtocolEncoder<RoomOpen3Request> = (
req: RoomOpen3Request
) => {
const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() });
bodyList.push({
type: PacketBodyValue.String,
value: req.isTimerRoom === true ? 'Y' : 'N'
});
bodyList.push({
type: PacketBodyValue.Integer,
value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval
});
for (const userSeq of req.userSeqs) {
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
}
return bodyList;
};
export const decodeRoomOpen3: ProtocolDecoder<RoomOpen3Response> = (
message: ProtocolMessage
) => {
return {
divCd: message.bodyList[0],
roomName: message.bodyList[1],
roomSeq: message.bodyList[2],
newRoom: message.bodyList[3] === 'Y' ? true : false,
isTimerRoom: message.bodyList[4] === 'Y' ? true : false,
timerRoomInterval: message.bodyList[5] || 0
} as RoomOpen3Response;
};

View File

@ -0,0 +1,72 @@
import {
ProtocolRequest,
ProtocolResponse,
ProtocolEncoder,
PacketBody,
PacketBodyValue,
ProtocolDecoder,
ProtocolMessage
} from '@ucap-webmessenger/protocol';
export interface RoomOpen4Request extends ProtocolRequest {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2. 타이머대화방여부YN(s)
isTimerRoom: boolean;
// 3. 타이머시간(n)
timerRoomInterval: number;
// 4n. 초대자 userSeq(n)...
userSeqs: number[];
}
export interface RoomOpen4Response extends ProtocolResponse {
// 0. 구분자
divCd: string;
// 1. 대화방제목(s)
roomName: string;
// 2. 대화방SEQ(s)
roomSeq: string;
// 3. 신규여부(y)
newRoom: boolean;
// 4. 타이머대화방여부YN(s)
isTimerRoom: boolean;
// 5. 타이머시간(n)
timerRoomInterval: number;
}
export const encodeRoomOpen4: ProtocolEncoder<RoomOpen4Request> = (
req: RoomOpen4Request
) => {
const bodyList: PacketBody[] = [];
bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() });
bodyList.push({
type: PacketBodyValue.String,
value: req.isTimerRoom === true ? 'Y' : 'N'
});
bodyList.push({
type: PacketBodyValue.Integer,
value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval
});
for (const userSeq of req.userSeqs) {
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
}
return bodyList;
};
export const decodeRoomOpen4: ProtocolDecoder<RoomOpen4Response> = (
message: ProtocolMessage
) => {
return {
divCd: message.bodyList[0],
roomName: message.bodyList[1],
roomSeq: message.bodyList[2],
newRoom: message.bodyList[3] === 'Y' ? true : false,
isTimerRoom: message.bodyList[4] === 'Y' ? true : false,
timerRoomInterval: message.bodyList[5] || 0
} as RoomOpen4Response;
};

View File

@ -1,8 +1,68 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol';
import {
SVC_TYPE_ROOM,
SSVC_TYPE_ROOM_OPEN_REQ,
SSVC_TYPE_ROOM_OPEN2_REQ,
SSVC_TYPE_ROOM_OPEN3_REQ,
SSVC_TYPE_ROOM_OPEN4_REQ
} from '../types/service';
import {
RoomOpenRequest,
encodeRoomOpen,
decodeRoomOpen,
RoomOpenResponse
} from '../models/room-open';
import {
RoomOpen2Request,
RoomOpen2Response,
decodeRoomOpen2,
encodeRoomOpen2
} from '../models/room-open2';
import {
RoomOpen3Request,
RoomOpen3Response,
encodeRoomOpen3,
decodeRoomOpen3
} from '../models/room-open3';
import {
RoomOpen4Request,
RoomOpen4Response,
encodeRoomOpen4,
decodeRoomOpen4
} from '../models/room-open4';
@Injectable({
providedIn: 'root'
})
export class RoomProtocolService {
constructor() {}
constructor(private protocolService: ProtocolService) {}
public roomOpen(req: RoomOpenRequest): Observable<RoomOpenResponse> {
return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeRoomOpen(req))
.pipe(map(res => decodeRoomOpen(res)));
}
public roomOpen2(req: RoomOpen2Request): Observable<RoomOpen2Response> {
return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req))
.pipe(map(res => decodeRoomOpen2(res)));
}
public roomOpen3(req: RoomOpen3Request): Observable<RoomOpen3Response> {
return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req))
.pipe(map(res => decodeRoomOpen3(res)));
}
public roomOpen4(req: RoomOpen4Request): Observable<RoomOpen4Response> {
return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req))
.pipe(map(res => decodeRoomOpen4(res)));
}
}

View File

@ -0,0 +1,43 @@
export const SVC_TYPE_ROOM = 10; // 대화방
export const SSVC_TYPE_ROOM_OPEN_REQ = 1; // 대화방 개설 요청
export const SSVC_TYPE_ROOM_OPEN_RES = 2;
export const SSVC_TYPE_ROOM_OPEN2_REQ = 3; // 대화방 개설 요청2
export const SSVC_TYPE_ROOM_OPEN2_RES = 4;
export const SSVC_TYPE_ROOM_OPEN3_REQ = 5; // 대화방 개설 요청3
export const SSVC_TYPE_ROOM_OPEN3_RES = 6;
export const SSVC_TYPE_ROOM_OPEN4_REQ = 7; // 대화방 개설 요청4
export const SSVC_TYPE_ROOM_OPEN4_RES = 8;
export const SSVC_TYPE_ROOM_INVITE_REQ = 11; // 초대 요청
export const SSVC_TYPE_ROOM_INVITE_RES = 12;
export const SSVC_TYPE_ROOM_INVITE_NOTI = 13;
export const SSVC_TYPE_ROOM_INFO_REQ = 21; // 대화방 정보 요청
export const SSVC_TYPE_ROOM_INFO_ROOM = 22; // 대화방 정보
export const SSVC_TYPE_ROOM_INFO_USER = 23; // 참가자 정보
export const SSVC_TYPE_ROOM_INFO_USER2 = 25; // 참가자 정보(상세)
export const SSVC_TYPE_ROOM_INFO_RES = 24; // 대화방 정보 완료
export const SSVC_TYPE_ROOM_INFO_SIMPLE_REQ = 26; // 대화방 정보 요청
// export const SSVC_TYPE_ROOM_INFO_ROOM = 22; // 대화방 정보
// export const SSVC_TYPE_ROOM_INFO_USER = 25; // 참가자 정보(상세)
export const SSVC_TYPE_ROOM_INFO_SIMPLE_RES = 27; // 대화방 정보 완료
export const SSVC_TYPE_ROOM_UPD_REQ = 31; // 대화방 변경 요청
export const SSVC_TYPE_ROOM_UPD_RES = 32;
export const SSVC_TYPE_ROOM_INFO_UPD_REQ = 33; // 대화방 정보 변경 요청
export const SSVC_TYPE_ROOM_INFO_UPD_RES = 34; // 대화방 정보 변경 응답
export const SSVC_TYPE_ROOM_FONT_UPD_REQ = 35; // 대화방 옵션 변경 요청
export const SSVC_TYPE_ROOM_FONT_UPD_NOTI = 36; // 대화방 옵션 변경 알림
export const SSVC_TYPE_ROOM_FONT_UPD_RES = 37; // 대화방 옵션 변경 응답
export const SSVC_TYPE_ROOM_DEL_REQ = 41; // 대화방 삭제 요청
export const SSVC_TYPE_ROOM_DEL_RES = 42;
export const SSVC_TYPE_ROOM_EXIT_REQ = 51; // 퇴장 요청
export const SSVC_TYPE_ROOM_EXIT_RES = 52;
export const SSVC_TYPE_ROOM_EXIT_NOTI = 53;
export const SSVC_TYPE_ROOM_EXIT_ALL_REQ = 61; // 전체 대화방 퇴장 요청
export const SSVC_TYPE_ROOM_EXIT_ALL_RES = 62; // 전체 대화방 퇴장 응답
export const SSVC_TYPE_ROOM_EXIT_FORCING_REQ = 54; // 대화상대 강퇴 요청
export const SSVC_TYPE_ROOM_EXIT_FORCING_NOTI = 55; // 대화상대 강퇴 알림
export const SSVC_TYPE_ROOM_EXIT_FORCING_RES = 56; // 대화상대 강퇴 응답
export const SSVC_TYPE_ROOM_USER_STATUS_REQ = 71; // 대화상대 오프라인 체크 요청
export const SSVC_TYPE_ROOM_USER_STATUS_RES = 72; // 대화상대 오프라인 체크 응답