iipEventEventOccurred method

void iipEventEventOccurred(
  1. int resourceId,
  2. int index,
  3. TransmissionType dataType,
  4. DC data,
)

Implementation

void iipEventEventOccurred(
    int resourceId, int index, TransmissionType dataType, DC data) {
  fetch(resourceId, null).then((r) {
    // push to the queue to gaurantee serialization
    var item = new AsyncReply<DistributedResourceQueueItem>();
    _queue.add(item);

    Codec.parse(data, 0, this, null, dataType).reply.then((arguments) {
      var et = r.instance?.template.getEventTemplateByIndex(index);
      if (et != null) {
        item.trigger(new DistributedResourceQueueItem(
            r, DistributedResourceQueueItemType.Event, arguments, index));
      } else {
        // ft found, fi not found, this should never happen
        _queue.remove(item);
      }
    });
  });

  /*
        if (resources.Contains(resourceId))
        {
            // push to the queue to gaurantee serialization
            var reply = new AsyncReply<DistributedResourceQueueItem>();
            var r = resources[resourceId];

            queue.Add(reply);

            Codec.parseVarArray(content, this).then((arguments) =>
            {
                if (!r.IsAttached)
                {
                    // event occurred before the template is received
                    r.AddAfterAttachement(reply,
                                            new DistributedResourceQueueItem((DistributedResource)r,
                                      DistributedResourceQueueItem.DistributedResourceQueueItemType.Event, arguments, index));
                }
                else
                {
                    var et = r.instance.template.GetEventTemplate(index);
                    if (et != null)
                    {
                        reply.trigger(new DistributedResourceQueueItem((DistributedResource)r,
                                      DistributedResourceQueueItem.DistributedResourceQueueItemType.Event, arguments, index));
                    }
                    else
                    {    // ft found, fi not found, this should never happen
                        queue.Remove(reply);
                    }
                }
            });
        }
        */
}