public void Send(uint?nextHop, Response response) { if (Constants.EnableDebug) { Debug.Log(comms.Node.Id + " -> " + nextHop + "\t : " + response.GetType() + ": " + response.ResponseCode + "." + "\t dst: " + response.DestinationID); } SatelliteComms hop = SatManager._instance.satellites.Find(sat => sat.Node.Id == nextHop); SatManager.MessageProps message = new SatManager.MessageProps(BackendHelpers.UnityVectorFromNumerics(comms.Node.Position), BackendHelpers.UnityVectorFromNumerics(hop.Node.Position), Color.cyan, Constants.SEND_DURATION_TIME / Constants.TimeScale); satMan.SentMessages.Add(message); if (System.Numerics.Vector3.Distance(comms.Node.Position, hop.Node.Position) < Constants.ScaleToSize(comms.CommRadius)) { hop.Node.CommsModule.Receive(response); ActiveCommSat = hop; ActiveCommSat = null; } }
public void Send(uint?nextHop, Request request) { request.SenderID = comms.Node.Id; SatelliteComms hop = SatManager._instance.satellites.Find(sat => sat.Node.Id == nextHop); SatManager.MessageProps message = new SatManager.MessageProps( BackendHelpers.UnityVectorFromNumerics(comms.Node.Position), BackendHelpers.UnityVectorFromNumerics(hop.Node.Position), Color.yellow, Constants.SEND_DURATION_TIME / Constants.TimeScale); switch (request.Command) { case Request.Commands.DETECTFAILURE: message.Color = Color.red; break; case Request.Commands.HEARTBEAT: message.Color = Color.red; break; case Request.Commands.PING: message.Color = Color.red; break; case Request.Commands.DISCOVER: message.Color = Color.green; break; case Request.Commands.POSITION: message.Color = Color.green; break; case Request.Commands.ADDITION: message.Color = Color.green; break; case Request.Commands.GENERATE: message.Color = Color.yellow; break; case Request.Commands.EXECUTE: message.Color = Color.yellow; break; } satMan.SentMessages.Add(message); if (System.Numerics.Vector3.Distance(comms.Node.Position, hop.Node.Position) < Constants.ScaleToSize(comms.CommRadius)) { ActiveCommSat = hop; if (request.MessageIdentifer == null) { request.MessageIdentifer = DateTime.Now.ToString() + " milli " + DateTime.Now.Millisecond; } if (Constants.EnableDebug) { Debug.Log(request.Dir + ": " + comms.Node.Id + " -> " + nextHop + "\t : " + request.Command.ToString() + "\t dst: " + request.DestinationID + "\t msgID: " + request.MessageIdentifer); } hop.Node.CommsModule.Receive(request); ActiveCommSat = null; } else { if (Constants.EnableDebug) { Debug.Log(request.Dir + ": " + comms.Node.Id + " -> " + nextHop + "\t : " + request.Command.ToString() + "\t dst: " + request.DestinationID + "\t msgID: " + request.MessageIdentifer); } } }