Esempio n. 1
0
    public IRemoteUser SendFriendResult(long user, bool answer)
    {
        string data;

        using (HttpClient web = new())
        {
            web.DefaultRequestHeaders.Add("token", Token);
            data = web.PostAsync($"https://{Domain}/Luski/api/{API_Ver}/FriendRequestResult", new StringContent(JsonRequest.FriendRequestResult(user, answer))).Result.Content.ReadAsStringAsync().Result;
        }

        IncomingHTTP?json = JsonSerializer.Deserialize(data, IncomingHTTPContext.Default.IncomingHTTP);

        if (json?.error is null && json?.data is not null)
        {
            if (answer)
            {
                string?temp = json.data.ToString();
                if (!string.IsNullOrEmpty(temp))
                {
                    FriendRequestResult?FRR = JsonSerializer.Deserialize <FriendRequestResult>(temp);
                    if (FRR is not null && FRR.channel is not null)
                    {
                        SocketChannel chan = SocketChannel.GetChannel((long)FRR.channel);
                        _ = chan.StartKeyProcessAsync();
                        chans.Add(chan);
                    }
                }
            }
        }