mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-01-08 01:29:58 +01:00
renamed CallAsync as Invoke
This commit is contained in:
parent
8fe0c086bb
commit
45d6e330bc
|
|
@ -205,7 +205,7 @@ foreach (User contact in contacts.users.Values)
|
|||
The second method uses the more complex GDPR export, **takeout session** system.
|
||||
Here is an example on how to implement it:
|
||||
```csharp
|
||||
using TL.Methods; // methods structures, for InvokeWithTakeout
|
||||
using TL.Methods; // methods as structures, for Invoke* calls
|
||||
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
await client.LoginUserIfNeeded();
|
||||
|
|
|
|||
|
|
@ -755,7 +755,7 @@ namespace WTelegram
|
|||
return request;
|
||||
}
|
||||
|
||||
internal async Task<X> CallBareAsync<X>(IMethod<X> request)
|
||||
internal async Task<X> InvokeBare<X>(IMethod<X> request)
|
||||
{
|
||||
if (_bareRequest != 0) throw new ApplicationException("A bare request is already undergoing");
|
||||
var msgId = await SendAsync(request, false);
|
||||
|
|
@ -766,14 +766,14 @@ namespace WTelegram
|
|||
return (X)await tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>Call the given TL method <i>(You shouldn't need to call this, usually)</i></summary>
|
||||
/// <summary>Call the given TL method <i>(You shouldn't need to use this method directly)</i></summary>
|
||||
/// <typeparam name="X">Expected type of the returned object</typeparam>
|
||||
/// <param name="request">TL method object</param>
|
||||
/// <param name="query">TL method structure</param>
|
||||
/// <returns>Wait for the reply and return the resulting object, or throws an RpcException if an error was replied</returns>
|
||||
public async Task<X> CallAsync<X>(IMethod<X> request)
|
||||
public async Task<X> Invoke<X>(IMethod<X> query)
|
||||
{
|
||||
retry:
|
||||
var msgId = await SendAsync(request, true);
|
||||
var msgId = await SendAsync(query, true);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
lock (_pendingRequests)
|
||||
_pendingRequests[msgId] = (typeof(X), tcs);
|
||||
|
|
@ -819,7 +819,7 @@ namespace WTelegram
|
|||
case ReactorError:
|
||||
goto retry;
|
||||
default:
|
||||
throw new ApplicationException($"{request.GetType().Name} call got a result of type {result.GetType().Name} instead of {typeof(X).Name}");
|
||||
throw new ApplicationException($"{query.GetType().Name} call got a result of type {result.GetType().Name} instead of {typeof(X).Name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -298,17 +298,17 @@ namespace TL
|
|||
public static class MTProtoExtensions
|
||||
{
|
||||
public static Task<ResPQ> ReqPq(this Client client, Int128 nonce)
|
||||
=> client.CallBareAsync(new ReqPq
|
||||
=> client.InvokeBare(new ReqPq
|
||||
{
|
||||
nonce = nonce,
|
||||
});
|
||||
public static Task<ResPQ> ReqPqMulti(this Client client, Int128 nonce)
|
||||
=> client.CallBareAsync(new ReqPqMulti
|
||||
=> client.InvokeBare(new ReqPqMulti
|
||||
{
|
||||
nonce = nonce,
|
||||
});
|
||||
public static Task<ServerDHParams> ReqDHParams(this Client client, Int128 nonce, Int128 server_nonce, byte[] p, byte[] q, long public_key_fingerprint, byte[] encrypted_data)
|
||||
=> client.CallBareAsync(new ReqDHParams
|
||||
=> client.InvokeBare(new ReqDHParams
|
||||
{
|
||||
nonce = nonce,
|
||||
server_nonce = server_nonce,
|
||||
|
|
@ -318,39 +318,39 @@ namespace TL
|
|||
encrypted_data = encrypted_data,
|
||||
});
|
||||
public static Task<SetClientDHParamsAnswer> SetClientDHParams(this Client client, Int128 nonce, Int128 server_nonce, byte[] encrypted_data)
|
||||
=> client.CallBareAsync(new SetClientDHParams
|
||||
=> client.InvokeBare(new SetClientDHParams
|
||||
{
|
||||
nonce = nonce,
|
||||
server_nonce = server_nonce,
|
||||
encrypted_data = encrypted_data,
|
||||
});
|
||||
public static Task<DestroyAuthKeyRes> DestroyAuthKey(this Client client)
|
||||
=> client.CallBareAsync(new DestroyAuthKey
|
||||
=> client.InvokeBare(new DestroyAuthKey
|
||||
{
|
||||
});
|
||||
public static Task<RpcDropAnswer> RpcDropAnswer(this Client client, long req_msg_id)
|
||||
=> client.CallBareAsync(new Methods.RpcDropAnswer
|
||||
=> client.InvokeBare(new Methods.RpcDropAnswer
|
||||
{
|
||||
req_msg_id = req_msg_id,
|
||||
});
|
||||
public static Task<FutureSalts> GetFutureSalts(this Client client, int num)
|
||||
=> client.CallAsync(new GetFutureSalts
|
||||
=> client.Invoke(new GetFutureSalts
|
||||
{
|
||||
num = num,
|
||||
});
|
||||
public static Task<Pong> Ping(this Client client, long ping_id)
|
||||
=> client.CallAsync(new Ping
|
||||
=> client.Invoke(new Ping
|
||||
{
|
||||
ping_id = ping_id,
|
||||
});
|
||||
public static Task<Pong> PingDelayDisconnect(this Client client, long ping_id, int disconnect_delay)
|
||||
=> client.CallAsync(new PingDelayDisconnect
|
||||
=> client.Invoke(new PingDelayDisconnect
|
||||
{
|
||||
ping_id = ping_id,
|
||||
disconnect_delay = disconnect_delay,
|
||||
});
|
||||
public static Task<DestroySessionRes> DestroySession(this Client client, long session_id)
|
||||
=> client.CallBareAsync(new DestroySession
|
||||
=> client.InvokeBare(new DestroySession
|
||||
{
|
||||
session_id = session_id,
|
||||
});
|
||||
|
|
|
|||
812
src/TL.Schema.cs
812
src/TL.Schema.cs
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue