diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/call-update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/call-update.ts index dfb34efa..25e6f0aa 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/call-update.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/call-update.ts @@ -14,7 +14,6 @@ import { CallForwardType } from '@ucap-webmessenger/core'; -// tslint:disable-next-line: no-empty-interface export interface CallUpdateRequest extends ProtocolRequest { // 0 IPPhoneYN(s) useIpPhone: boolean; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts index ab69df7f..c4376e03 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/reg-update.ts @@ -10,7 +10,6 @@ import { PacketBodyValue } from '@ucap-webmessenger/protocol'; -// tslint:disable-next-line: no-empty-interface export interface RegUpdateRequest extends ProtocolRequest { // 0 알림방법(n) notificationMethod: NotificationMethod; diff --git a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/update.ts b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/update.ts index b6646199..5c867bba 100644 --- a/projects/ucap-webmessenger-protocol-option/src/lib/protocols/update.ts +++ b/projects/ucap-webmessenger-protocol-option/src/lib/protocols/update.ts @@ -8,7 +8,6 @@ import { PacketBodyValue } from '@ucap-webmessenger/protocol'; -// tslint:disable-next-line: no-empty-interface export interface UpdateRequest extends ProtocolRequest { // 알람여부(y) receiveAlarm: boolean; diff --git a/projects/ucap-webmessenger-protocol-ping/src/lib/protocols/ping.ts b/projects/ucap-webmessenger-protocol-ping/src/lib/protocols/ping.ts new file mode 100644 index 00000000..f0db9e61 --- /dev/null +++ b/projects/ucap-webmessenger-protocol-ping/src/lib/protocols/ping.ts @@ -0,0 +1,34 @@ +import { + ProtocolRequest, + ProtocolResponse, + ProtocolEncoder, + PacketBody, + ProtocolDecoder, + ProtocolMessage, + PacketBodyValue +} from '@ucap-webmessenger/protocol'; + +export interface PingRequest extends ProtocolRequest { + /** 상태코드(s) */ + statusCode: string; +} + +// tslint:disable-next-line: no-empty-interface +export interface PingResponse extends ProtocolResponse {} + +export const encodePing: ProtocolEncoder = (req: PingRequest) => { + const bodyList: PacketBody[] = []; + + bodyList.push({ + type: PacketBodyValue.String, + value: req.statusCode + }); + + return bodyList; +}; + +export const decodePing: ProtocolDecoder = ( + message: ProtocolMessage +) => { + return {} as PingResponse; +}; diff --git a/projects/ucap-webmessenger-protocol-ping/src/lib/services/ping-protocol.service.ts b/projects/ucap-webmessenger-protocol-ping/src/lib/services/ping-protocol.service.ts index 82e533fd..2e570501 100644 --- a/projects/ucap-webmessenger-protocol-ping/src/lib/services/ping-protocol.service.ts +++ b/projects/ucap-webmessenger-protocol-ping/src/lib/services/ping-protocol.service.ts @@ -1,8 +1,29 @@ import { Injectable } from '@angular/core'; +import { ProtocolService } from '@ucap-webmessenger/protocol'; + +import { Observable } from 'rxjs'; +import { take, map } from 'rxjs/operators'; + +import { + PingRequest, + PingResponse, + encodePing, + decodePing +} from '../protocols/ping'; +import { SVC_TYPE_PING, SSVC_TYPE_PING_REQ } from '../types/service'; @Injectable({ providedIn: 'root' }) export class PingProtocolService { - constructor() {} + constructor(private protocolService: ProtocolService) {} + + public ping(req: PingRequest): Observable { + return this.protocolService + .call(SVC_TYPE_PING, SSVC_TYPE_PING_REQ, ...encodePing(req)) + .pipe( + take(1), + map(res => decodePing(res)) + ); + } } diff --git a/projects/ucap-webmessenger-protocol-ping/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol-ping/src/lib/types/service.ts new file mode 100644 index 00000000..044a5d7f --- /dev/null +++ b/projects/ucap-webmessenger-protocol-ping/src/lib/types/service.ts @@ -0,0 +1,4 @@ +export const SVC_TYPE_PING = 99; + +export const SSVC_TYPE_PING_REQ = 1; +export const SSVC_TYPE_PING_RES = 2; diff --git a/projects/ucap-webmessenger-protocol-ping/src/public-api.ts b/projects/ucap-webmessenger-protocol-ping/src/public-api.ts index 6e0259ee..82235eff 100644 --- a/projects/ucap-webmessenger-protocol-ping/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol-ping/src/public-api.ts @@ -4,4 +4,6 @@ export * from './lib/services/ping-protocol.service'; +export * from './lib/types/service'; + export * from './lib/ucap-ping-protocol.module';