//new Server want to join DHT
        public object Post(JoinParentDto req)
        {
            DHTServerCtx.DHT.Parent = req.Parent;

            log.Info (string.Format ("{0} joined as parent", DHTServerCtx.DHT.Parent));
            log.Debug (DHTServerCtx.DHT);
            return new HttpResult {
                StatusCode = HttpStatusCode.Accepted
            };
        }
Example #2
0
        private static void joinMyNewChild(string myPublicUrl)
        {
            var client      = new RestClient(DHTServerCtx.DHT.Child);
            var requestPath = (RouteAttribute)Attribute.GetCustomAttribute(typeof(JoinParentDto), typeof(RouteAttribute));
            var request     = new RestRequest(requestPath.Path, Method.POST);
            var data        = new JoinParentDto {
                Parent = myPublicUrl
            };

            request.AddJsonBody(data);

            Console.WriteLine("Sending join as parent request to {0} {1}", client.BaseUrl, requestPath.Path);
            var response = client.Execute <JoinParentDtoResponse> (request);

            Console.WriteLine("Joined as parent with code {0}", response.StatusCode);
        }