/*Please use this method for reading the conf file*/ private void ReadConfigurationFile() { string current_dir = System.IO.Directory.GetCurrentDirectory(); XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object. xmlDoc.Load(_configFile); //* load the XML document from the specified file. XmlNodeList puppetmasteriplist = xmlDoc.GetElementsByTagName("PuppetMasterIP"); XmlNodeList puppetmasterportlist = xmlDoc.GetElementsByTagName("PuppetMasterPort"); XmlNodeList serverslist = xmlDoc.GetElementsByTagName("Server"); _puppetIP = puppetmasteriplist[0].InnerText; _puppetPort = Convert.ToInt32(puppetmasterportlist[0].InnerText); _servers = new List<ServerMetadata>(); for (int i = 0; i < 3; i++) { //TODO: currently just reading first server XmlNodeList server_ipportlist = serverslist[i].ChildNodes; string id = server_ipportlist[0].InnerText; string ip_addr = server_ipportlist[1].InnerText; int port = Convert.ToInt32(server_ipportlist[2].InnerText); ServerMetadata sm = new ServerMetadata(); sm.Username = id; sm.IP_Addr = ip_addr; sm.Port = port; _servers.Add(sm); } }
public bool registerServer(string username, string ip_addr, int port) { ServerMetadata sm = new ServerMetadata(); sm.Username = username; sm.IP_Addr = ip_addr; sm.Port = port; //adding the client metadata to the global hashtable so that it can be used later on servers_list.Add(username, sm); IServerFacade isf = connectToServerFacadeService(sm); serverFacadeList.Add(username, isf); Gui.updateServersTree(sm, null); return true; }
private IServerFacade connectToServerFacadeService(ServerMetadata sm) { String connectionString = "tcp://" + sm.IP_Addr + ":" + sm.Port + "/" + sm.Username + "/" + Common.Constants.SERVER_FACADE_SERVICE; IDictionary RemoteChannelProperties = new Dictionary<string, string>(); RemoteChannelProperties["name"] = sm.Username; TcpChannel server_channel = new TcpChannel(RemoteChannelProperties, null, null); ChannelServices.RegisterChannel(server_channel, true); //TODO: uncomment and fix this to make it work IServerFacade facadeService = (IServerFacade)Activator.GetObject( typeof(IServerFacade), connectionString); return facadeService; }
private IConsistencyService getOtherServers(ServerMetadata servers) { ServerMetadata chosenServer = servers; String connectionString = "tcp://" + chosenServer.IP_Addr + ":" + chosenServer.Port + "/" + servers.Username + "/" + Common.Constants.CONSISTENCY_SERVICE_NAME; Log.Show(_username, "Trying to find server: " + connectionString); IConsistencyService server = (IConsistencyService)Activator.GetObject( typeof(IConsistencyService), connectionString); return server; }