public void HandleEvent(object sender, MulticastMessageEventArgs args)
        {
            if ((this.HandleMessage != null) && (args != null))
            {
                string jsonString = args.JsonString;

                if (!string.IsNullOrEmpty(jsonString))
                {
                    using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)))
                    {
                        try
                        {
                            JsonRpcResponse          response     = (JsonRpcResponse)this.deserializer.ReadObject(ms);
                            JsonRpcResponseEventArgs responseArgs = new JsonRpcResponseEventArgs();
                            responseArgs.Response = response;
                            this.HandleMessage(this, responseArgs);
                        }
                        catch (SerializationException)
                        {
                            return;
                        }
                    }
                }
            }
        }
示例#2
0
        private void HandleEvent(object sender, JsonRpcResponseEventArgs args)
        {
            JsonRpcResponse response = args.Response;

            if ((response.Result != null) || (response.Error != null))
            {
                string queryId = response.Id;
                if (!string.IsNullOrEmpty(queryId))
                {
                    lock (this.awaitingResponses)
                    {
                        ConfigQuery query;
                        if (this.awaitingResponses.TryGetValue(queryId, out query))
                        {
                            this.awaitingResponses.Remove(queryId);
                            query.Timer.Stop();

                            if (response.Error != null)
                            {
                                query.Callbacks.OnError(response);
                            }
                            else
                            {
                                query.Callbacks.OnSuccess(response);
                            }
                        }
                    }
                }
            }
        }