コード例 #1
0
        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));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }