ping protocol is implemented

This commit is contained in:
병준 박 2019-10-08 16:24:31 +09:00
parent fa070c24d7
commit f72100c4f5
7 changed files with 62 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<PingRequest> = (req: PingRequest) => {
const bodyList: PacketBody[] = [];
bodyList.push({
type: PacketBodyValue.String,
value: req.statusCode
});
return bodyList;
};
export const decodePing: ProtocolDecoder<PingResponse> = (
message: ProtocolMessage
) => {
return {} as PingResponse;
};

View File

@ -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<PingResponse> {
return this.protocolService
.call(SVC_TYPE_PING, SSVC_TYPE_PING_REQ, ...encodePing(req))
.pipe(
take(1),
map(res => decodePing(res))
);
}
}

View File

@ -0,0 +1,4 @@
export const SVC_TYPE_PING = 99;
export const SSVC_TYPE_PING_REQ = 1;
export const SSVC_TYPE_PING_RES = 2;

View File

@ -4,4 +4,6 @@
export * from './lib/services/ping-protocol.service';
export * from './lib/types/service';
export * from './lib/ucap-ping-protocol.module';