SP-152 unsubscribe support
This commit is contained in:
1 parent
f2d284cadb
commit
03bbf2f4a8
6 files changed
+43
-12
No files matched your search
@@ -41,7 +41,6 @@ function gen_subscribe(service:IService, method_id : number, methodName : string
|
||||
console.log(`--subscribe-- ${service.name}:${method_id}`)
|
||||
return service.context.subscribe(service.name, service.qualifier, method_id, methodName, qualifier, (updates) => {
|
||||
// iterate and decode each update
|
||||
// create an Update<t>
|
||||
let result : Update<any> = { all: {}, added: {}, changed: {}, removed: {} };
|
||||
updates.forEach((value:RawUpdate) => {
|
||||
const key = value.key;
|
||||
@@ -76,6 +75,11 @@ function gen_subscribe(service:IService, method_id : number, methodName : string
|
||||
});
|
||||
}
|
||||
}
|
||||
function gen_unsubscribe(service:IService) {
|
||||
return (id:number) => {
|
||||
service.context.unsubscribe(id, service.name, service.qualifier);
|
||||
};
|
||||
}
|
||||
|
||||
export class DynamicService {
|
||||
constructor(
|
||||
@@ -91,6 +95,7 @@ export class DynamicService {
|
||||
for (var [streamName,id,typeName] of streams) {
|
||||
const fnName = "subscribe_" + streamName;
|
||||
this[fnName] = gen_subscribe(svc, id, streamName, typeName)
|
||||
this["un"+fnName] = gen_unsubscribe(svc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,8 +206,8 @@ export class ServiceContext {
|
||||
return id;
|
||||
}
|
||||
|
||||
unsubscribe(subscriptionId : number) {
|
||||
let req = GatewayUnsubscribe.crate({ subscriptionId});
|
||||
unsubscribe(subscriptionId : number, serviceType : string, serviceQualifier : string) {
|
||||
let req = GatewayUnsubscribe.create({subscriptionId, serviceType, serviceQualifier});
|
||||
let message = GatewayRequest.create({
|
||||
unsubscribe: req
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user