Beispiel #1
0
        public override Task Send(IConnection connection, string data, string connectionData)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            string url = UrlBuilder.BuildSend(connection, Name, connectionData);

            var postData = new Dictionary <string, string> {
                { "data", data }
            };

            return(HttpClient.Post(url, connection.PrepareRequest, postData, isLongRunning: false)
                   .Then(response => response.ReadAsString())
                   .Then(raw =>
            {
                if (!String.IsNullOrEmpty(raw))
                {
                    connection.Trace(TraceLevels.Messages, "OnMessage({0})", raw);

                    connection.OnReceived(connection.JsonDeserializeObject <JObject>(raw));
                }
            })
                   .Catch(connection.OnError, connection));
        }