iipRequestListen method
void
iipRequestListen(
- int callback,
- int resourceId,
- int index
)
Implementation
void iipRequestListen(int callback, int resourceId, int index) {
Warehouse.getById(resourceId).then((r) {
if (r != null) {
var et = r.instance?.template.getEventTemplateByIndex(index);
if (et != null) {
if (r is DistributedResource) {
r.listen(et.name).then((x) {
sendReply(IIPPacketAction.Listen, callback).done();
}).error((x) => sendError(ErrorType.Exception, callback,
ExceptionCode.GeneralFailure.index));
} else {
// if (!subscriptions.ContainsKey(r))
// {
// sendError(ErrorType.Management, callback, ExceptionCode.NotAttached.index);
// return;
// }
// if (subscriptions[r].Contains(index))
// {
// sendError(ErrorType.Management, callback, ExceptionCode.AlreadyListened.index);
// return;
// }
// subscriptions[r].add(index);
// sendReply(IIPPacketAction.Listen, callback).done();
}
} else {
// pt not found
sendError(ErrorType.Management, callback,
ExceptionCode.MethodNotFound.index);
}
} else {
// resource not found
sendError(ErrorType.Management, callback,
ExceptionCode.ResourceNotFound.index);
}
});
}