iipRequestUnlisten method

void iipRequestUnlisten(
  1. int callback,
  2. int resourceId,
  3. int index
)

Implementation

void iipRequestUnlisten(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.unlisten(et.name).then((x) {
            sendReply(IIPPacketAction.Unlisten, callback).done();
          }).error((x) => sendError(ErrorType.Exception, callback,
              ExceptionCode.GeneralFailure.index));
        } else {
          // if (!subscriptions.ContainsKey(r))
          // {
          //     SendError(ErrorType.Management, callback, (ushort)ExceptionCode.NotAttached);
          //     return;
          // }

          // if (!subscriptions[r].Contains(index))
          // {
          //     SendError(ErrorType.Management, callback, (ushort)ExceptionCode.AlreadyUnlistened);
          //     return;
          // }

          // subscriptions[r].Remove(index);

          // SendReply(IIPPacket.IIPPacketAction.Unlisten, callback).Done();
        }
      } else {
        // pt not found
        sendError(ErrorType.Management, callback,
            ExceptionCode.MethodNotFound.index);
      }
    } else {
      // resource not found
      sendError(ErrorType.Management, callback,
          ExceptionCode.ResourceNotFound.index);
    }
  });
}