Exemplo n.º 1
0
        internal async Task <bool> SendMessageAsync(string content, int userid)
        {
            try
            {
                JSONRepresentations.Post.Message m = new JSONRepresentations.Post.Message()
                {
                    message = content,
                    to      = userid
                };

                SparklrResponse <string> result = await webClient.PostJsonAsyncRawResponse("chat", m);

                if (result.IsOkAndTrue())
                {
                    return(true);
                }
                else if (result.Code == System.Net.HttpStatusCode.BadRequest)
                {
                    throw new ArgumentException("The message you wanted to send was not accepted by the server, maybe it was too long?", content);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exceptions.NotAuthorizedException)
            {
                throw new Exceptions.NotAuthorizedException("You are either not authorized or blocked by the specified user.");
            }
        }
Exemplo n.º 2
0
        internal async Task<bool> SendMessageAsync(string content, int userid)
        {
            try
            {
                JSONRepresentations.Post.Message m = new JSONRepresentations.Post.Message()
                                                            {
                                                                message = content,
                                                                to = userid
                                                            };

                SparklrResponse<string> result = await webClient.PostJsonAsyncRawResponse("chat", m);

                if (result.IsOkAndTrue())
                {
                    return true;
                }
                else if (result.Code == System.Net.HttpStatusCode.BadRequest)
                {
                    throw new ArgumentException("The message you wanted to send was not accepted by the server, maybe it was too long?", content);
                }
                else
                {
                    return false;
                }
            }
            catch (Exceptions.NotAuthorizedException)
            {
                throw new Exceptions.NotAuthorizedException("You are either not authorized or blocked by the specified user.");
            }
        }