Esempio n. 1
0
        /// <summary>
        /// Connects the specified remote host.
        /// </summary>
        /// <param name="remoteHost">The remote host.</param>
        /// <param name="remotePort">The remote port.</param>
        /// <param name="pushMessageServerHost">The push message server host.</param>
        /// <param name="pushMessageServerPort">The push message server port.</param>
        /// <returns><c>true</c> if connected, <c>false</c> otherwise.</returns>
        public static bool Connect(string remoteHost, ushort remotePort, string pushMessageServerHost, ushort pushMessageServerPort)
        {
            try
            {
                bool result = false;

                if (Controller != null)
                {
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Remote host is already connected.");
                }
                else
                {
                    Controller = new TddAppComController(remoteHost, remotePort, pushMessageServerHost, pushMessageServerPort);
                    Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Establishing connection to remote host.");
                    if (Controller == null)
                    {
                        Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Establishing connection to remote host failed!!!");
                    }
                    else
                    {
                        result = true;
                        Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Connection to remote host established.");
                    }
                }

                return(result);
            }
            catch (Exception e)
            {
                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Establishing connection failed. " + e);
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Disconnects this instance.
        /// </summary>
        /// <returns><c>true</c> if disconnected, <c>false</c> otherwise.</returns>
        public static bool Disconnect()
        {
            try
            {
                if (Controller != null)
                {
                    Controller.UnregisterPushMessageServer();
                    Controller.Dispose();
                    Controller = null;
                }

                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Disconnecting from remote host.");
                return(true);
            }
            catch (Exception e)
            {
                Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Disconnecting failed. " + e);
                return(false);
            }
        }