// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2026 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from TfwEventService.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.tfw {
  public class EventService : ObjectProxy {

    static public readonly new TypeInfo typeInfo = new TypeInfo("tfw.EventService:1.0.0", null);

    public EventService(Agent agent, string rid, TypeInfo ti) : base(agent, rid, ti) {}
    public EventService(Agent agent, string rid) : this(agent, rid, typeInfo) {}

    public static new EventService StaticCast(ObjectProxy proxy) {
      return proxy == null ? null : new EventService(proxy.Agent, proxy.Rid, proxy.StaticTypeInfo);
    }

    public class CreateChannelResult {
      public Com.Raritan.Idl.tfw.EventChannel _ret_;
    }

    public CreateChannelResult createChannel() {
      JsonObject _parameters = null;
      var _result = RpcCall("createChannel", _parameters);
      var _ret = new CreateChannelResult();
      _ret._ret_ = Com.Raritan.Idl.tfw.EventChannel.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
      return _ret;
    }

    public AsyncRequest createChannel(AsyncRpcResponse<CreateChannelResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return createChannel(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest createChannel(AsyncRpcResponse<CreateChannelResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("createChannel", _parameters,
        _result => {
          try {
            var _ret = new CreateChannelResult();
            _ret._ret_ = Com.Raritan.Idl.tfw.EventChannel.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class DestroyChannelResult {
    }

    public DestroyChannelResult destroyChannel(Com.Raritan.Idl.tfw.EventChannel channel) {
      var _parameters = new LightJson.JsonObject();
      _parameters["channel"] = channel != null ? channel.Encode() : JsonValue.Null;

      var _result = RpcCall("destroyChannel", _parameters);
      var _ret = new DestroyChannelResult();
      return _ret;
    }

    public AsyncRequest destroyChannel(Com.Raritan.Idl.tfw.EventChannel channel, AsyncRpcResponse<DestroyChannelResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return destroyChannel(channel, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest destroyChannel(Com.Raritan.Idl.tfw.EventChannel channel, AsyncRpcResponse<DestroyChannelResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["channel"] = channel != null ? channel.Encode() : JsonValue.Null;
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("destroyChannel", _parameters,
        _result => {
          try {
            var _ret = new DestroyChannelResult();
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
