unlisten method

AsyncReply unlisten(
  1. dynamic event
)

Implementation

AsyncReply<dynamic> unlisten(event) {
  if (_destroyed) throw new Exception("Trying to access a destroyed object.");
  if (_suspended) throw new Exception("Trying to access a suspended object.");

  EventTemplate? et = event is EventTemplate
      ? event
      : instance?.template.getEventTemplateByName(event.toString());

  if (et == null)
    return AsyncReply().triggerError(new AsyncException(
        ErrorType.Management, ExceptionCode.MethodNotFound.index, ""));

  if (!et.listenable)
    return AsyncReply().triggerError(new AsyncException(
        ErrorType.Management, ExceptionCode.NotListenable.index, ""));

  return _connection?.sendUnlistenRequest(_instanceId as int, et.index)
      as AsyncReply;
}