private bool HandleCompare(RequestEventArgs e, NetworkRequest req) { var verb = new CompareVerb(model); NetworkRequest result = verb.ProcessRequest(req); byte[] data = Encoding.UTF8.GetBytes(result.Data); var generator = new ResponseWriter(); e.Response.ContentLength.Value = data.Length; generator.SendHeaders(e.Context, e.Response); e.Context.Stream.Write(data, 0, data.Length); e.Context.Stream.Flush(); data = null; return true; }
private void RunAsync(object o) { lock (sync) { requests++; } var node = o as Node; if (null != node) { var client = new Client(model.LocalNode); var verb = new CompareVerb(model); if (client.Execute(verb, node)) { if (!verb.Allowed) { verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "Denied"; data.Add(verb.Node); } else { verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "OK"; data.Add(verb.Node); } } else { verb.Node = new CompareNode(); verb.Node.Nickname = node.Nickname; verb.Node.Location = node.Location; verb.Node.Status = "Error"; data.Add(verb.Node); } } lock (sync) { requests--; viewModel.Status = "Status: Waiting for a response from " + requests + " peers.."; if (requests == 0) { viewModel.EnableRun = true; viewModel.Status = "Status: All Information recieved, click start to refresh info (Note clients will cache information for 5 minutes)."; } } }