take 처리

This commit is contained in:
leejh 2019-09-23 15:17:48 +09:00
parent 6f067dcc15
commit 226af990b0
3 changed files with 47 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map, take } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
@ -40,18 +40,27 @@ export class BuddyProtocolService {
public buddyAdd(req: BuddyAddRequest): Observable<BuddyAddResponse> { public buddyAdd(req: BuddyAddRequest): Observable<BuddyAddResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeBuddyAdd(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_ADD_REQ, ...encodeBuddyAdd(req))
.pipe(map(res => decodeBuddyAdd(res))); .pipe(
take(1),
map(res => decodeBuddyAdd(res))
);
} }
public buddyDel(req: BuddyDelRequest): Observable<BuddyDelResponse> { public buddyDel(req: BuddyDelRequest): Observable<BuddyDelResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeBuddyDel(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_DEL_REQ, ...encodeBuddyDel(req))
.pipe(map(res => decodeBuddyDel(res))); .pipe(
take(1),
map(res => decodeBuddyDel(res))
);
} }
public buddyUpdate(req: BuddyUpdateRequest): Observable<BuddyUpdateResponse> { public buddyUpdate(req: BuddyUpdateRequest): Observable<BuddyUpdateResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeBuddyUpdate(req)) .call(SVC_TYPE_BUDDY, SSVC_TYPE_BUDDY_UPD_REQ, ...encodeBuddyUpdate(req))
.pipe(map(res => decodeBuddyUpdate(res))); .pipe(
take(1),
map(res => decodeBuddyUpdate(res))
);
} }
} }

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map, take } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import { import {
@ -40,19 +40,28 @@ export class GroupProtocolService {
public groupAdd(req: GroupAddRequest): Observable<GroupAddResponse> { public groupAdd(req: GroupAddRequest): Observable<GroupAddResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_ADD_REQ, ...encodeGroupAdd(req))
.pipe(map(res => decodeGroupAdd(res))); .pipe(
take(1),
map(res => decodeGroupAdd(res))
);
} }
public groupDel(req: GroupDelRequest): Observable<GroupDelResponse> { public groupDel(req: GroupDelRequest): Observable<GroupDelResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_DEL_REQ, ...encodeGroupDel(req))
.pipe(map(res => decodeGroupDel(res))); .pipe(
take(1),
map(res => decodeGroupDel(res))
);
} }
public groupUpdate(req: GroupUpdateRequest): Observable<GroupUpdateResponse> { public groupUpdate(req: GroupUpdateRequest): Observable<GroupUpdateResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req)) .call(SVC_TYPE_GROUP, SSVC_TYPE_GROUP_UPD_REQ, ...encodeGroupUpdate(req))
.pipe(map(res => decodeGroupUpdate(res))); .pipe(
take(1),
map(res => decodeGroupUpdate(res))
);
} }
public groupUpdate2( public groupUpdate2(
@ -64,6 +73,9 @@ export class GroupProtocolService {
SSVC_TYPE_GROUP_UPD_REQ2, SSVC_TYPE_GROUP_UPD_REQ2,
...encodeGroupUpdate2(req) ...encodeGroupUpdate2(req)
) )
.pipe(map(res => decodeGroupUpdate2(res))); .pipe(
take(1),
map(res => decodeGroupUpdate2(res))
);
} }
} }

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map, take } from 'rxjs/operators';
import { ProtocolService } from '@ucap-webmessenger/protocol'; import { ProtocolService } from '@ucap-webmessenger/protocol';
import { import {
@ -45,24 +45,36 @@ export class RoomProtocolService {
public roomOpen(req: RoomOpenRequest): Observable<RoomOpenResponse> { public roomOpen(req: RoomOpenRequest): Observable<RoomOpenResponse> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeRoomOpen(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN_REQ, ...encodeRoomOpen(req))
.pipe(map(res => decodeRoomOpen(res))); .pipe(
take(1),
map(res => decodeRoomOpen(res))
);
} }
public roomOpen2(req: RoomOpen2Request): Observable<RoomOpen2Response> { public roomOpen2(req: RoomOpen2Request): Observable<RoomOpen2Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN2_REQ, ...encodeRoomOpen2(req))
.pipe(map(res => decodeRoomOpen2(res))); .pipe(
take(1),
map(res => decodeRoomOpen2(res))
);
} }
public roomOpen3(req: RoomOpen3Request): Observable<RoomOpen3Response> { public roomOpen3(req: RoomOpen3Request): Observable<RoomOpen3Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN3_REQ, ...encodeRoomOpen3(req))
.pipe(map(res => decodeRoomOpen3(res))); .pipe(
take(1),
map(res => decodeRoomOpen3(res))
);
} }
public roomOpen4(req: RoomOpen4Request): Observable<RoomOpen4Response> { public roomOpen4(req: RoomOpen4Request): Observable<RoomOpen4Response> {
return this.protocolService return this.protocolService
.call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req)) .call(SVC_TYPE_ROOM, SSVC_TYPE_ROOM_OPEN4_REQ, ...encodeRoomOpen4(req))
.pipe(map(res => decodeRoomOpen4(res))); .pipe(
take(1),
map(res => decodeRoomOpen4(res))
);
} }
} }