// Constructor for the Network Node State internal NetworkNodeState(string name, string inputFile) { // Initialize the fields _inputFile = inputFile; _forwardingMutex = new SemaphoreSlim(1, 1); _forwardingTable = new ForwardingTable(); _neighborsEndpoints = new Dictionary <string, IPEndPoint?>(); _neighborsCost = new Dictionary <string, double>(); // Add the node itself to the forwarding table _forwardingTable.UpsertPath(name, 0, null); // Try to read and parse the contents of the file try { // Get all the lines of the file var fileContents = File.ReadAllLines(inputFile); // For each line the the file but the first foreach (var line in fileContents[1..])
// Static method to encode a forwarding table to be sent internal static string Encode(ForwardingTable forwardingTable) { return(forwardingTable.Encode()); }