/* * You should not call this method directly. Instead, call HandleAdjacentNodesAfterNodeRemoval() */ private void HandleNetworkResolving(List <ElectricNetworkNode> nodesToBeResolved) { NetworkResolver networkResolver = new NetworkResolver(); networkResolver.ResolveNetworks(nodesToBeResolved); List <ElectricNetworkSeed> resolvedNetworkSeeds = networkResolver.resolvedNetworkSeeds; // If only one ElectricNetworkSeed gets returned, it means that the network doesn't break up. Just one node gets removed. if (resolvedNetworkSeeds.Count == 1) { return; } // Because all former nodes and edges now are reassigned in resolved network seeds, it is save to wipe all // content from the network before removal (unregister all nodes and edges). ElectricNetwork networkBeforeRemoval = nodesToBeResolved[0].connectedNetwork; ElectricNetworkUtil.RemoveNetworkContent(networkBeforeRemoval); // Reassign the biggest networkSeed to the network before the removal ElectricNetworkUtil.SortBySize(resolvedNetworkSeeds); ElectricNetworkSeed biggestNetworkSeed = resolvedNetworkSeeds[0]; ElectricNetworkUtil.AddNetworkContent(networkBeforeRemoval, biggestNetworkSeed); Debug.Log($"INFO: There are {biggestNetworkSeed.nodes.Count} nodes in the biggest network after removing a node. "); resolvedNetworkSeeds.Remove(biggestNetworkSeed); // For every other networkSeed: Create a new network and populate it with the contents of the networkSeed foreach (ElectricNetworkSeed networkSeed in resolvedNetworkSeeds) { ElectricNetwork electricNetwork = CreateNewElectricNetwork(); networkSeed.nodes.ForEach(node => ElectricNetworkUtil.Register(electricNetwork, node)); networkSeed.edges.ForEach(edge => ElectricNetworkUtil.Register(electricNetwork, edge)); } }
public Form1() { InitializeComponent(); Database s = Database.Instance; ServerNetworkInputHandler snih = new ServerNetworkInputHandler(); SocketResourcesManager.srm = new SocketResourcesManager(snih); ServerCommunicationCenter.commCenter = new ServerCommunicationCenter( NetworkResolver.ProvideServerSocket(), NetworkResolver.serverPort); ServerCommunicationCenter.commCenter.StartListening(); ServerObjectGraph.sog = new ServerObjectGraph(); UdpHpServer.uhps = new UdpHpServer(); }
public void StartApp(int port) { string fileName = "master.dat"; ApplicationLiveData.ald = new ApplicationLiveData(port); ClientCommunicationCenter.commCenter = new ClientCommunicationCenter(NetworkResolver.ProvideClientSocket(port), port); ApplicationLiveData.ald.LocalEndPoint = ClientCommunicationCenter.commCenter.Socket.LocalEndPoint; ApplicationLiveData.ald.Port = port; ClientNetworkInputHandler.nic = new ClientNetworkInputHandler(); SocketResourcesManager.srm = new SocketResourcesManager(ClientNetworkInputHandler.nic); ClientCommunicationCenter.commCenter.StartListening(); ApplicationLiveData.ald.ServerEndPoint = NetworkResolver.ResolveServerEndPoint(); MasterFileManager.mfm = new MasterFileManager(fileName, this); MasterFileManager.mfm.InitMasterFile(); FileRegistrationManager.frm = new FileRegistrationManager(); ClientHashReceiver.chr = new ClientHashReceiver(); NewFileTransferManager.nftm = new NewFileTransferManager(); UdpHpClient.uhc = new UdpHpClient(); FileTransferCenter.ftc = new FileTransferCenter(); }
internal Messaging(NetworkResolver resolver) { this.resolver = resolver; Current = this; }