public string VoteAction(ChooserLbMessage message) { var _storage = NodeStorage.GetInstance(); NodeData worker; var selected_Nodes = Distributor.FormateNodeList(3, out worker); var neighbors = Mapping.Mapper.Map <List <NodeNeighbor> >(selected_Nodes); var request_data = new NodeVoteMessage() { Message = message, Neighbours = neighbors }; var serialized = JsonConvert.SerializeObject(request_data); var content = new StringContent(serialized, Encoding.UTF8, "application/json"); try { var response = worker.Sender.PostAsync(new Uri(new Uri(worker.IpAddress), "api/Vote"), content).Result; return(response.Content.ReadAsStringAsync().Result); } catch (Exception e) { return("Error connection to Node" + e.Message); } }
public NodeVoteMessage FormateMessage(ChooserLbMessage message) { var data = new NodeVoteMessage(); data.message = message; data.NeighBours = ChoosedNodes.ToList(); return(data); }