public ManualAsyncResult BeginGetNearestNodesInfo(SupernodeStructures.Location location) { var asyncResult = new ManualAsyncResult { Path = "/nodes/nearest", Bytes = encoding.GetBytes(JsonConvert.SerializeObject(location)) }; return(new HttpConnector(Connection).PreparePostRequest(asyncResult)); }
public void SetNearestNode(SupernodeStructures.Location location) { var client = new SupernodeClient(); if (location.numNodes > 25) { throw new ArgumentException("invalid number of nodes"); } client.BeginGetNearestNodesInfo(ar => { for (var i = 0; i < ar.Content.data.Count; i++) { if (ar.Content.data[i].status != 1) { continue; } SetHost(ar.Content.data[i].ip); break; } }, location).AsyncWaitHandle.WaitOne(); }
public ManualAsyncResult BeginGetNearestNodesInfo(Action <ResponseAccessor <SupernodeResponseData.NearestNodes> > callback, SupernodeStructures.Location location) { if (location.numNodes > 25) { throw new ArgumentException("Number of nodes must be 25 or less"); } var asyncResult = new ManualAsyncResult { Path = "/nodes/nearest", Bytes = encoding.GetBytes(JsonConvert.SerializeObject(location)) }; return(new HttpAsyncConnector(Connection).PreparePostRequestAsync(callback, asyncResult)); }