/// <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); }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { if (@object is TdApi.UpdateAuthorizationState) { OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState); } else { // Print("Unsupported update: " + @object); if (@object is TdApi.UpdateChatLastMessage) { ///RDV - -1001408447562 ///HIDE -1001352498778 ///my -1001260330650 TdApi.Message lastMessage = (@object as TdApi.UpdateChatLastMessage).LastMessage; if (lastMessage != null && appConfig.chatIds.Contains(lastMessage.ChatId)) { var saveMessage = new SaveMessage(); saveMessage.messageID = lastMessage.Id; if (db.SaveMessage.Find(lastMessage.Id) == null) { db.SaveMessage.Add(saveMessage); db.SaveChanges(); sendMessage(lastMessage); // Print(lastMessage.ToString()); } } } } }
public void OnResult(TdApi.BaseObject obj) { _cnt--; if (_cnt == 0) { _page.Print("DONE"); } }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { if (@object is TdApi.UpdateAuthorizationState) { OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState); } else { // Print("Unsupported update: " + @object); } }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { if (@object is TdApi.Error) { Print("Receive an error:" + _newLine + @object); OnAuthorizationStateUpdated(null); // repeat last action } else { // result is already received through UpdateAuthorizationState, nothing to do } }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { if (@object is TdApi.UpdateAuthorizationState) { //OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState); Console.WriteLine("Missing 2"); } else { // Print("Unsupported update: " + @object); } }
public void OnResult(tdapi.BaseObject @object) { if (commands.ContainsKey(command)) { commands[command].Invoke(@object, this); } else { if (core.mainresponsehandlers.ContainsKey(@object.GetType())) { Action <TDLibCoreEventArgs> handler = core.mainresponsehandlers[@object.GetType()]; if (handler != null) { handler(new TDLibCoreEventArgs() { core = core, additionalobject = @object }); } } } }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { Print(@object.ToString()); }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { Print(@object.ToString()); // sendMessage(GetChatId("350715255"), @object.ToString()); }
public void OnResult(TdApi.BaseObject obj) { var str = obj.ToString(); _page.Print(str); }
void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object) { //Print(@object.ToString()); Console.WriteLine("Missing 1" + @object.ToString()); }
public void OnResult(TdApi.BaseObject @object) { flag = false; baseObject = @object; flag = true; }