private void CreateClient(String[] clientUrl, String clientId, String serverUrl, String scriptName) { safeSleep(); String clientIp = clientUrl[0]; IMSDADPCS pcs = (IMSDADPCS)Activator.GetObject(typeof(IMSDADPCS), "tcp://" + clientIp + ":10000/PCS"); if (pcs != null) { String fullUrl = "tcp://" + clientIp + ":" + clientUrl[1] + "/" + clientUrl[2]; String args = String.Format("{0} {1} {2} {3} {4} {5}", clientId, clientUrl[1], clientUrl[2], serverUrl, scriptName, clientIp); pcs.CreateProcess("Client", args); IMSDADClientPuppet remoteRef = (IMSDADClientPuppet)Activator.GetObject(typeof(IMSDADClientPuppet), fullUrl); if (remoteRef != null) { this.Clients.Add(new Puppet(clientId, fullUrl), remoteRef); } else { this.textBox1.Text += String.Format("Client at URL {0} was not created", fullUrl); } } else { this.textBox1.Text += String.Format("Unable to contact PCS at ip {0}", clientIp); } }
private void CreateServer(String[] url, String serverId, String maxFaults, String minDelay, String maxDelay) { //Contact PCS safeSleep(); String ip = url[0]; IMSDADPCS pcs = (IMSDADPCS)Activator.GetObject(typeof(IMSDADPCS), "tcp://" + ip + ":10000/PCS"); if (pcs != null) { String args = String.Format("{0} {1} {2} {3} {4} {5} {6}", url[0], serverId, url[2], url[1], maxFaults, minDelay, maxDelay); //Give Server URL of all Servers currently running String servers = ""; foreach (Puppet server in this.Servers.Keys) { servers += server.serverUrl + " "; } args += String.Format(" {0} {1}", this.Servers.Values.Count, servers); //Give Server All Locations String locals = ""; foreach (PuppetRoom room in this.Locations) { locals += room.ToString() + " "; } args += String.Format("{0} {1}", this.Locations.Count, locals); //Contact Server and get Ref pcs.CreateProcess("Server", args); String fullUrl = "tcp://" + ip + ":" + url[1] + "/" + url[2]; IMSDADServerPuppet remoteRef = (IMSDADServerPuppet)Activator.GetObject(typeof(IMSDADServerPuppet), fullUrl); if (remoteRef != null) { this.Servers.Add(new Puppet(serverId, fullUrl), remoteRef); } else { this.textBox1.Text += String.Format("Server at URL {0} was not created", fullUrl); } } else { this.textBox1.Text += String.Format("Unable to contact PCS at ip {0}", ip); } }