public static TdApi.BaseObject Send(TdApi.Function function) { var handler = new CustomDefaultHandler(); _client.Send(function, handler); return(handler.GetBaseObject()); }
/// <summary> /// asynchronously run a tdapi.Function /// </summary> /// <param name="func">function you want to run asynchronously</param> /// <param name="expectedtype">the type which you expect your function response receives</param> /// <returns>A Responseobject contains your task information</returns> public async Task <Responseobject> ExecuteCommandAsync(tdapi.Function func, tdapi.BaseObject expectedtype = null) { Responseobject res = new Responseobject(); Dictionary <string, Action <tdapi.BaseObject, Reshandler> > customcommands = new Dictionary <string, Action <tdapi.BaseObject, Reshandler> >(); customcommands.Add("Custom", (a, b) => { b.responseobject = a; if (expectedtype is null) { b.response = enums.Response.Success; } else { if (a.GetType() == expectedtype.GetType()) { b.response = enums.Response.Success; } else { b.response = enums.Response.Failed; } } }); Reshandler handler = new Reshandler(this) { command = "Custom", }; ReadCommands(handler, customcommands); client.Send(func, handler); res = await handler.getresponse(); return(res); }