using FLY.OBJComponents.IService;
using FLY.OBJComponents.OBJ_INTERFACE;
using FObjBase;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.OBJComponents.Client
{
    public class JsonDistServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IJsonDistService
    {
        protected override Type InterfaceType => typeof(IJsonDistService);


        public JsonDistServiceClient(UInt32 serviceId) : base(serviceId) { }
        
        public JsonDistServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }


        public event EventHandler ValueChanged;


        public void Trigger_ValueChanged(JsonDistValueChangedEventArgs e)
        {
            ValueChanged?.Invoke(this, e);
        }

        public void GetValue(string key, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetValue), new { key }, asyncDelegate, asyncContext);
        }

        public void SetValue(string key, JObject value)
        {
            Call(nameof(SetValue), new { key, value });
        }
    }
}