diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-add.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/add.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-add.ts rename to projects/ucap-webmessenger-protocol-buddy/src/lib/models/add.ts diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-del.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/del.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-del.ts rename to projects/ucap-webmessenger-protocol-buddy/src/lib/models/del.ts diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-update.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/models/update.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-buddy/src/lib/models/buddy-update.ts rename to projects/ucap-webmessenger-protocol-buddy/src/lib/models/update.ts diff --git a/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts b/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts index 365fd17c..adc52dc7 100644 --- a/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-buddy/src/lib/services/buddy-protocol.service.ts @@ -17,19 +17,19 @@ import { encodeBuddyAdd, decodeBuddyAdd, BuddyAddResponse -} from '../models/buddy-add'; +} from '../models/add'; import { BuddyDelRequest, encodeBuddyDel, decodeBuddyDel, BuddyDelResponse -} from '../models/buddy-del'; +} from '../models/del'; import { BuddyUpdateRequest, decodeBuddyUpdate, encodeBuddyUpdate, BuddyUpdateResponse -} from '../models/buddy-update'; +} from '../models/update'; @Injectable({ providedIn: 'root' diff --git a/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts b/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts index 90da4389..826985ea 100644 --- a/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-buddy/src/public-api.ts @@ -1,9 +1,9 @@ /* * Public API Surface of ucap-webmessenger-protocol-buddy */ -export * from './lib/models/buddy-add'; -export * from './lib/models/buddy-del'; -export * from './lib/models/buddy-update'; +export * from './lib/models/add'; +export * from './lib/models/del'; +export * from './lib/models/update'; export * from './lib/services/buddy-protocol.service'; diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-add.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/add.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-group/src/lib/models/group-add.ts rename to projects/ucap-webmessenger-protocol-group/src/lib/models/add.ts diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-del.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/del.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-group/src/lib/models/group-del.ts rename to projects/ucap-webmessenger-protocol-group/src/lib/models/del.ts diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/models/group-update.ts b/projects/ucap-webmessenger-protocol-group/src/lib/models/update.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-group/src/lib/models/group-update.ts rename to projects/ucap-webmessenger-protocol-group/src/lib/models/update.ts diff --git a/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts b/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts index 9649ad8a..57079fcc 100644 --- a/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service.ts @@ -9,7 +9,7 @@ import { encodeGroupAdd, decodeGroupAdd, GroupAddResponse -} from '../models/group-add'; +} from '../models/add'; import { SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, @@ -22,7 +22,7 @@ import { encodeGroupDel, decodeGroupDel, GroupDelResponse -} from '../models/group-del'; +} from '../models/del'; import { GroupUpdateRequest, encodeGroupUpdate, @@ -30,7 +30,7 @@ import { encodeGroupUpdate2, decodeGroupUpdate2, GroupUpdateResponse -} from '../models/group-update'; +} from '../models/update'; @Injectable({ providedIn: 'root' }) diff --git a/projects/ucap-webmessenger-protocol-group/src/public-api.ts b/projects/ucap-webmessenger-protocol-group/src/public-api.ts index 766deaca..517ea747 100644 --- a/projects/ucap-webmessenger-protocol-group/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-group/src/public-api.ts @@ -1,9 +1,9 @@ /* * Public API Surface of ucap-webmessenger-protocol-group */ -export * from './lib/models/group-add'; -export * from './lib/models/group-del'; -export * from './lib/models/group-update'; +export * from './lib/models/add'; +export * from './lib/models/del'; +export * from './lib/models/update'; export * from './lib/services/group-protocol.service'; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/exit.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/exit.ts new file mode 100644 index 00000000..733e78bb --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/exit.ts @@ -0,0 +1,123 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; +import { RoomExitType } from '../types/room.type'; + +export interface RoomExitRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; +} + +export interface RoomExitResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; +} + +export const encodeRoomExit: ProtocolEncoder = ( + req: RoomExitRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + return bodyList; +}; + +export const decodeRoomExit: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0] + } as RoomExitResponse; +}; +export const decodeRoomExitNotification: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0] + } as RoomExitResponse; +}; + +export interface RoomExitAllRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string[]; +} + +export const encodeRoomAllExit: ProtocolEncoder = ( + req: RoomExitAllRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq.join(',') }); + return bodyList; +}; + +export interface RoomExitForcingRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 강퇴요청타입(s) + type: string; + // sender사용자SEQ(n) + senderSeq: number; + // 사용자SEQ(n)... + userSeqs: number[]; +} + +export interface RoomExitForcingResponse extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 강퇴요청타입(s) + type: RoomExitType; + // sender사용자SEQ(n) + senderSeq: number; + // 사용자SEQ(n)... + userSeqs: number[]; +} + +export const encodeRoomExitForcing: ProtocolEncoder = ( + req: RoomExitForcingRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + bodyList.push({ type: PacketBodyValue.String, value: req.type }); + bodyList.push({ type: PacketBodyValue.Integer, value: req.senderSeq }); + req.userSeqs.forEach(userSeq => { + bodyList.push({ type: PacketBodyValue.Integer, value: userSeq }); + }); + return bodyList; +}; + +export const decodeRoomExitForcing: ProtocolDecoder = ( + message: ProtocolMessage +) => { + let userSeqs: number[] = []; + if (message.bodyList.length > 3) { + userSeqs = message.bodyList.slice(3); + } + return { + roomSeq: message.bodyList[0], + type: message.bodyList[1] as RoomExitType, + senderSeq: message.bodyList[2], + userSeqs + } as RoomExitForcingResponse; +}; +export const decodeRoomExitForcingNotification: ProtocolDecoder< + RoomExitForcingResponse +> = (message: ProtocolMessage) => { + let userSeqs: number[] = []; + if (message.bodyList.length > 3) { + userSeqs = message.bodyList.slice(3); + } + return { + roomSeq: message.bodyList[0], + type: message.bodyList[1] as RoomExitType, + senderSeq: message.bodyList[2], + userSeqs + } as RoomExitForcingResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts similarity index 89% rename from projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts rename to projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts index a76dd4ac..8afcf2f3 100644 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-info.ts +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/info.ts @@ -203,7 +203,7 @@ export const decodeRoomInfoData: ProtocolDecoder = ( if (info.length > 11) { roomInfo = { roomSeq: info[0], - roomType: info[1], + roomType: info[1] as RoomType, roomName: info[2], finalEventType: info[3] as EventType, finalEventMessage: info[4], @@ -300,3 +300,35 @@ export const decodeRoomUserData: ProtocolDecoder = ( userInfos } as RoomUserDataResponse; }; + +export interface RoomUserStatusOfflineRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; +} + +export interface RoomUserStatusOfflineResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 사용자SEQ(n)... + userSeqs: number[]; +} +export const encodeRoomUserStatusOffline: ProtocolEncoder< + RoomUserStatusOfflineRequest +> = (req: RoomUserStatusOfflineRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + return bodyList; +}; +export const decodeRoomUserStatusOffline: ProtocolDecoder< + RoomUserStatusOfflineResponse +> = (message: ProtocolMessage) => { + let userSeqs: number[] = []; + if (message.bodyList.length > 1) { + userSeqs = message.bodyList.slice(1); + } + return { + roomSeq: message.bodyList[0], + userSeqs + } as RoomUserStatusOfflineResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-invite.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/invite.ts similarity index 100% rename from projects/ucap-webmessenger-protocol-room/src/lib/models/room-invite.ts rename to projects/ucap-webmessenger-protocol-room/src/lib/models/invite.ts diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/open.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/open.ts new file mode 100644 index 00000000..bc000b6d --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/open.ts @@ -0,0 +1,220 @@ +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 = ( + 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 = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomSeq: message.bodyList[1], + newRoom: message.bodyList[2] === 'Y' ? true : false + } as RoomOpenResponse; +}; + +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 = ( + 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 = ( + message: ProtocolMessage +) => { + return { + divCd: message.bodyList[0], + roomName: message.bodyList[1], + roomSeq: message.bodyList[2], + newRoom: message.bodyList[3] === 'Y' ? true : false + } as RoomOpen2Response; +}; + +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 = ( + 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 = ( + 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; +}; + +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 = ( + 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 = ( + 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[4] !== 'Y' ? 0 : message.bodyList[5] || 0 + } as RoomOpen4Response; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts deleted file mode 100644 index f3c334a3..00000000 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open.ts +++ /dev/null @@ -1,48 +0,0 @@ -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 = ( - 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 = ( - message: ProtocolMessage -) => { - return { - divCd: message.bodyList[0], - roomSeq: message.bodyList[1], - newRoom: message.bodyList[2] === 'Y' ? true : false - } as RoomOpenResponse; -}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts deleted file mode 100644 index cc148195..00000000 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open2.ts +++ /dev/null @@ -1,54 +0,0 @@ -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 = ( - 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 = ( - message: ProtocolMessage -) => { - return { - divCd: message.bodyList[0], - roomName: message.bodyList[1], - roomSeq: message.bodyList[2], - newRoom: message.bodyList[3] === 'Y' ? true : false - } as RoomOpen2Response; -}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts deleted file mode 100644 index ddf7d4bf..00000000 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open3.ts +++ /dev/null @@ -1,72 +0,0 @@ -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 = ( - 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 = ( - 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; -}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts deleted file mode 100644 index 35cf2da5..00000000 --- a/projects/ucap-webmessenger-protocol-room/src/lib/models/room-open4.ts +++ /dev/null @@ -1,73 +0,0 @@ -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 = ( - 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 = ( - 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[4] !== 'Y' ? 0 : message.bodyList[5] || 0 - } as RoomOpen4Response; -}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/models/update.ts b/projects/ucap-webmessenger-protocol-room/src/lib/models/update.ts new file mode 100644 index 00000000..33f70daf --- /dev/null +++ b/projects/ucap-webmessenger-protocol-room/src/lib/models/update.ts @@ -0,0 +1,142 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + PacketBodyValue, + ProtocolDecoder, + ProtocolMessage +} from '@ucap-webmessenger/protocol'; + +export interface RoomUpdateRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 대화방제목(s) + roomName: string; + // 알람여부(y) + isAlarm: boolean; + // 동기화여부(s) + isSyncAll: boolean; +} + +export interface RoomUpdateResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 대화방제목(s) + roomName: string; + // 알람여부(y) + isAlarm: boolean; + // 동기화여부(s) + isSyncAll: boolean; +} + +export const encodeRoomUpdate: ProtocolEncoder = ( + req: RoomUpdateRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + bodyList.push({ type: PacketBodyValue.String, value: req.roomName }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.isAlarm ? 'Y' : 'N' + }); + bodyList.push({ + type: PacketBodyValue.String, + value: req.isSyncAll ? 'Y' : 'N' + }); + return bodyList; +}; + +export const decodeRoomUpdate: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + roomName: message.bodyList[1], + isAlarm: message.bodyList[2] === 'Y' ? true : false, + isSyncAll: message.bodyList[3] === 'Y' ? true : false + } as RoomUpdateResponse; +}; + +export interface RoomUpdateTimerSetRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 타이머시간(n) + timerInterval: number; +} + +export interface RoomUpdateTimerSetResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 타이머시간(n) + timerInterval: number; +} + +export const encodeRoomUpdateTimerSet: ProtocolEncoder< + RoomUpdateTimerSetRequest +> = (req: RoomUpdateTimerSetRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + bodyList.push({ type: PacketBodyValue.Integer, value: req.timerInterval }); + return bodyList; +}; + +export const decodeRoomUpdateTimerSet: ProtocolDecoder< + RoomUpdateTimerSetResponse +> = (message: ProtocolMessage) => { + return { + roomSeq: message.bodyList[0], + timerInterval: message.bodyList[1] || 0 + } as RoomUpdateTimerSetResponse; +}; + +export interface RoomUpdateFontRequest extends ProtocolRequest { + // 대화방SEQ(s) + roomSeq: string; + // 폰트색(s) cf)0x000000 형태의 스트링 + fontColor: string; + // sender사용자SEQ(n) + senderSeq: number; +} + +export interface RoomUpdateFontResponse extends ProtocolResponse { + // 대화방SEQ(s) + roomSeq: string; + // 폰트색(s) cf)0x000000 형태의 스트링 + fontColor: string; + // sender사용자SEQ(n) + senderSeq: number; +} + +export const encodeRoomUpdateFont: ProtocolEncoder = ( + req: RoomUpdateFontRequest +) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ type: PacketBodyValue.String, value: req.roomSeq }); + bodyList.push({ type: PacketBodyValue.String, value: req.fontColor }); + bodyList.push({ type: PacketBodyValue.Integer, value: req.senderSeq }); + return bodyList; +}; + +export const decodeRoomUpdateFont: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return { + roomSeq: message.bodyList[0], + fontColor: message.bodyList[1], + senderSeq: message.bodyList[2] + } as RoomUpdateFontResponse; +}; + +export const decodeRoomUpdateFontNotification: ProtocolDecoder< + RoomUpdateFontResponse +> = (message: ProtocolMessage) => { + return { + roomSeq: message.bodyList[0], + fontColor: message.bodyList[1], + senderSeq: message.bodyList[2] + } as RoomUpdateFontResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts b/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts index 6ad5bc2b..c0d40210 100644 --- a/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-room/src/lib/services/room-protocol.service.ts @@ -15,38 +15,39 @@ import { SSVC_TYPE_ROOM_INFO_RES, SSVC_TYPE_ROOM_INFO_REQ, SSVC_TYPE_ROOM_INFO_USER, - SSVC_TYPE_ROOM_INFO_USER2 + SSVC_TYPE_ROOM_INFO_USER2, + SSVC_TYPE_ROOM_EXIT_REQ, + SSVC_TYPE_ROOM_EXIT_ALL_REQ, + SSVC_TYPE_ROOM_EXIT_FORCING_REQ, + SSVC_TYPE_ROOM_USER_STATUS_REQ, + SSVC_TYPE_ROOM_UPD_REQ, + SSVC_TYPE_ROOM_INFO_UPD_REQ, + SSVC_TYPE_ROOM_FONT_UPD_REQ } from '../types/service'; import { RoomOpenRequest, encodeRoomOpen, decodeRoomOpen, - RoomOpenResponse -} from '../models/room-open'; -import { + RoomOpenResponse, RoomOpen2Request, RoomOpen2Response, decodeRoomOpen2, - encodeRoomOpen2 -} from '../models/room-open2'; -import { + encodeRoomOpen2, RoomOpen3Request, RoomOpen3Response, encodeRoomOpen3, - decodeRoomOpen3 -} from '../models/room-open3'; -import { + decodeRoomOpen3, RoomOpen4Request, RoomOpen4Response, encodeRoomOpen4, decodeRoomOpen4 -} from '../models/room-open4'; +} from '../models/open'; import { RoomInviteRequest, RoomInviteResponse, encodeRoomInvite, decodeRoomInvite -} from '../models/room-invite'; +} from '../models/invite'; import { RoomInfoRequest, RoomInfoResponse, @@ -57,8 +58,38 @@ import { decodeRoomInfoData, decodeRoomInfo, decodeRoomUserShortData, - decodeRoomUserData -} from '../models/room-info'; + decodeRoomUserData, + RoomUserStatusOfflineRequest, + RoomUserStatusOfflineResponse, + encodeRoomUserStatusOffline, + decodeRoomUserStatusOffline +} from '../models/info'; +import { + RoomExitRequest, + RoomExitResponse, + encodeRoomExit, + decodeRoomExit, + RoomExitAllRequest, + encodeRoomAllExit, + RoomExitForcingRequest, + RoomExitForcingResponse, + encodeRoomExitForcing, + decodeRoomExitForcing +} from '../models/exit'; +import { + RoomUpdateRequest, + RoomUpdateResponse, + encodeRoomUpdate, + decodeRoomUpdate, + RoomUpdateTimerSetRequest, + RoomUpdateTimerSetResponse, + encodeRoomUpdateTimerSet, + decodeRoomUpdateTimerSet, + RoomUpdateFontRequest, + RoomUpdateFontResponse, + encodeRoomUpdateFont, + decodeRoomUpdateFont +} from '../models/update'; @Injectable({ providedIn: 'root' @@ -74,7 +105,6 @@ export class RoomProtocolService { map(res => decodeRoomOpen(res)) ); } - public roomOpen2(req: RoomOpen2Request): Observable { return this.protocolService .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req)) @@ -83,7 +113,6 @@ export class RoomProtocolService { map(res => decodeRoomOpen2(res)) ); } - public roomOpen3(req: RoomOpen3Request): Observable { return this.protocolService .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req)) @@ -92,7 +121,6 @@ export class RoomProtocolService { map(res => decodeRoomOpen3(res)) ); } - public roomOpen4(req: RoomOpen4Request): Observable { return this.protocolService .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req)) @@ -136,4 +164,103 @@ export class RoomProtocolService { }) ); } + public roomUserStatusOffline( + req: RoomUserStatusOfflineRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_USER_STATUS_REQ, + ...encodeRoomUserStatusOffline(req) + ) + .pipe( + map(res => { + take(1); + return decodeRoomUserStatusOffline(res); + }) + ); + } + + public roomExit(req: RoomExitRequest): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_EXIT_REQ, ...encodeRoomExit(req)) + .pipe( + map(res => { + take(1); + return decodeRoomExit(res); + }) + ); + } + public roomExitAll(req: RoomExitAllRequest): Observable { + return this.protocolService + .call( + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_EXIT_ALL_REQ, + ...encodeRoomAllExit(req) + ) + .pipe( + map(res => { + take(1); + }) + ); + } + public roomExitForcing( + req: RoomExitForcingRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_EXIT_FORCING_REQ, + ...encodeRoomExitForcing(req) + ) + .pipe( + map(res => { + take(1); + return decodeRoomExitForcing(res); + }) + ); + } + + public roomUpdate(req: RoomUpdateRequest): Observable { + return this.protocolService + .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_UPD_REQ, ...encodeRoomUpdate(req)) + .pipe( + map(res => { + take(1); + return decodeRoomUpdate(res); + }) + ); + } + public roomUpdateTimerSet( + req: RoomUpdateTimerSetRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_INFO_UPD_REQ, + ...encodeRoomUpdateTimerSet(req) + ) + .pipe( + map(res => { + take(1); + return decodeRoomUpdateTimerSet(res); + }) + ); + } + public roomUpdateFont( + req: RoomUpdateFontRequest + ): Observable { + return this.protocolService + .call( + SVC_TYPE_ROOM, + SSVC_TYPE_ROOM_FONT_UPD_REQ, + ...encodeRoomUpdateFont(req) + ) + .pipe( + map(res => { + take(1); + return decodeRoomUpdateFont(res); + }) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts b/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts index 8c4e7b4e..a603195e 100644 --- a/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts +++ b/projects/ucap-webmessenger-protocol-room/src/lib/types/room.type.ts @@ -18,3 +18,8 @@ export enum RoomType { // K: MyTalk(나와의 대화) Mytalk = 'K' } + +export enum RoomExitType { + // A 만 사용하고 있고, 서버에서도 달리 처리하지는 않음, 하지만 추후 사용성을 위해 생성. + All = 'A' +} diff --git a/projects/ucap-webmessenger-protocol-room/src/public-api.ts b/projects/ucap-webmessenger-protocol-room/src/public-api.ts index 70b64234..f70bf8f3 100644 --- a/projects/ucap-webmessenger-protocol-room/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-room/src/public-api.ts @@ -2,12 +2,9 @@ * Public API Surface of ucap-webmessenger-protocol-room */ -export * from './lib/models/room-info'; -export * from './lib/models/room-invite'; -export * from './lib/models/room-open'; -export * from './lib/models/room-open2'; -export * from './lib/models/room-open3'; -export * from './lib/models/room-open4'; +export * from './lib/models/info'; +export * from './lib/models/invite'; +export * from './lib/models/open'; export * from './lib/services/room-protocol.service'; export * from './lib/types/employee.type';