Пример #1
0
        /// <summary>
        /// Create the Echelon service. Once created, it attempts to open the connection
        /// by calling Echelon.Connect(). If unsuccessful, it will throw an exception and
        /// null out the communicator.
        /// </summary>
        /// <param name="host">Host to connect to.</param>
        /// <param name="port">Port that the server listens on.</param>
        public static void ConnectToEchelon()
        {
            if (Echelon == null)
            {
                try
                {
                    Echelon            = new MasterCommunicator(ECHELON_HOST, ECHELON_PORT);
                    Echelon.ConfigFile = "config.client";
                    if (!Echelon.Connect())
                    {
                        Echelon.Disconnect();
                        Echelon = null;

                        throw new Exception("Unable to connect to " + ECHELON_HOST + ".");
                    }
                }
                catch (Exception)
                {
                    Echelon = null;
                    throw;
                }
            }
            else
            {
                throw new Exception("The communicator has already been created.");
            }
        }
Пример #2
0
        /// <summary>
        /// Internal method for creating the master communicator. It also
        /// performs the login.
        /// </summary>
        private void CreateMasterCommunicator()
        {
            MainServer         = new MasterCommunicator(ServerAddress.Host, ServerAddress.Port);
            MainServer.LogFile = AuthInfo.Username + "MasterConfig.log";
            if (!MainServer.Connect())
            {
                HandleError("Could not connect to the server: reason unknown.");
            }

            MainServer.Login(AuthInfo.Username, AuthInfo.Password,
                             new VTankObject.Version()); // TODO: Use real version.

            Debugger.Write("Login as {0} successful.", AuthInfo.Username);
        }
Пример #3
0
        /// <summary>
        /// Internal method for creating the master communicator. It also
        /// performs the login.
        /// </summary>
        private void CreateMasterCommunicator()
        {
            MainServer = new MasterCommunicator(ServerAddress.Host, ServerAddress.Port);
            MainServer.LogFile = AuthInfo.Username + "MasterConfig.log";
            if (!MainServer.Connect())
            {
                HandleError("Could not connect to the server: reason unknown.");
            }

            MainServer.Login(AuthInfo.Username, AuthInfo.Password,
                new VTankObject.Version()); // TODO: Use real version.

            Debugger.Write("Login as {0} successful.", AuthInfo.Username);
        }
Пример #4
0
        /// <summary>
        /// Create the Echelon service. Once created, it attempts to open the connection
        /// by calling Echelon.Connect(). If unsuccessful, it will throw an exception and
        /// null out the communicator.
        /// </summary>
        /// <param name="host">Host to connect to.</param>
        /// <param name="port">Port that the server listens on.</param>
        public static void ConnectToEchelon()
        {
            if (Echelon == null)
            {
                try
                {
                    Echelon = new MasterCommunicator(ECHELON_HOST, ECHELON_PORT);
                    Echelon.ConfigFile = "config.client";
                    if (!Echelon.Connect())
                    {
                        Echelon.Disconnect();
                        Echelon = null;

                        throw new Exception("Unable to connect to " + ECHELON_HOST + ".");
                    }
                }
                catch (Exception)
                {
                    Echelon = null;
                    throw;
                }
            }
            else
            {
                throw new Exception("The communicator has already been created.");
            }
        }