/// <summary> /// Add a new server to the list of available servers. /// </summary> /// <param name="HostName"></param> /// <param name="Port"></param> /// <param name="Protocol"></param> /// <returns></returns> public bool RegisterServer(String HostName, String Port, String Protocol, String Description) { // // Check to see if we already have this server registered if (m_Servers.ContainsKey(HostName + Port)) { return(true); } // // Make sure the Protocol channel has been successfully registered if (Protocol.ToUpper() == GPEnums.CHANNEL_TCP && !m_TcpRegistered) { return(false); } if (Protocol.ToUpper() == GPEnums.CHANNEL_HTTP && !m_HttpRegistered) { return(false); } // // Obtain the IGPServer interface String CompleteHost = Protocol.ToLower() + "://" + HostName + ":" + Port + "/" + GPEnums.SERVER_SOAPNAME; object obj = Activator.GetObject( typeof(IGPServer), CompleteHost); IGPServer iGPServer = (IGPServer)obj; // // Validate this server is available if (!ValidateServer(iGPServer)) { return(false); } // // Assign a sponsor for the remote object GPServerClientSponsor Sponsor = fmMain.SponsorServer.Create("GPServer Singleton"); ILease LeaseInfo = (ILease)((MarshalByRefObject)iGPServer).GetLifetimeService(); LeaseInfo.Register(Sponsor); m_Sponsors.Add(HostName + Port, Sponsor); // // Add this server interface to our singleton m_Servers.Add(HostName + Port, iGPServer); m_Descriptions.Add(HostName + Port, Description); return(true); }
/// <summary> /// Private thread that creates client sponsor objects as needed. /// </summary> /// <param name="arg"></param> private void SponsorThreadStart() { bool Done = false; while (!Done) { wh_Command.WaitOne(); // Wait for a command to come through wh_Command.Reset(); // Immediately reset the event // // Do something based upon the command given switch (m_Command) { case Command.Terminate: Done = true; break; case Command.CreateSponsor: m_SponsorRef = new GPServerClientSponsor(m_SponsorName); wh_CommandComplete.Set(); break; } } }