Exemplo n.º 1
0
        /// <summary>
        /// Close the connection to a DeploymentManager and stop any attempts to reconnect
        /// </summary>
        /// <param name="address">The Address of the DeploymentManager</param>
        public void CloseDeploymentManagerConnection(string address)
        {
            string ipAddress = STEM.Sys.IO.Net.MachineAddress(address);

            lock (ConnectionLock)
            {
                MessageConnection c = _MessageConnections.FirstOrDefault(i => i.RemoteAddress == ipAddress);

                if (c != null)
                {
                    c.AutoReconnect = false;
                    c.Close();
                }
            }
        }
Exemplo n.º 2
0
        void Handshake(object o)
        {
            MessageConnection connection = o as MessageConnection;

            STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Performing handshake with " + connection.RemoteAddress + ".", Sys.EventLog.EventLogEntryType.Information);

            int     retry    = 0;
            Message response = connection.Send(this, TimeSpan.FromSeconds(10));

            while ((response is Timeout) && (retry < 5))
            {
                STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake timeout with " + connection.RemoteAddress + ".", Sys.EventLog.EventLogEntryType.Information);
                response = connection.Send(this, TimeSpan.FromSeconds(10));
                retry++;
            }

            if (response is Timeout || response is Undeliverable)
            {
                connection.Close();
                return;
            }

            STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake completed with " + connection.RemoteAddress + ".", Sys.EventLog.EventLogEntryType.Information);
        }
Exemplo n.º 3
0
        void Handshake(object o)
        {
            MessageConnection connection = o as MessageConnection;

            try
            {
                if (connection.SessionID() != _ConnectionSessionID)
                {
                    STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake Undeliverable to " + connection.RemoteAddress + ".", Sys.EventLog.EventLogEntryType.Information);

                    if (onHandshakeComplete != null)
                    {
                        connection.Close();
                    }

                    return;
                }

                int port = connection.LocalPort;
                if (connection.ConnectionRole == Role.Server)
                {
                    port = connection.RemotePort;
                }

                STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Performing handshake with " + connection.RemoteAddress + ":" + port + ".", Sys.EventLog.EventLogEntryType.Information);

                Message response = connection.Send(this, TimeSpan.FromSeconds(15));

                if (response is Timeout)
                {
                    if (connection.SessionID() != _ConnectionSessionID)
                    {
                        STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake Undeliverable to " + connection.RemoteAddress + ":" + port + ".", Sys.EventLog.EventLogEntryType.Information);
                    }
                    else
                    {
                        STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake timeout with " + connection.RemoteAddress + ":" + port + ".", Sys.EventLog.EventLogEntryType.Information);
                    }

                    if (onHandshakeComplete != null)
                    {
                        connection.Close();
                    }

                    return;
                }

                if (response is Undeliverable)
                {
                    STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake Undeliverable to " + connection.RemoteAddress + ":" + port + ".", Sys.EventLog.EventLogEntryType.Information);

                    if (onHandshakeComplete != null)
                    {
                        connection.Close();
                    }

                    return;
                }

                if (onHandshakeComplete != null)
                {
                    try
                    {
                        onHandshakeComplete(this, connection);
                    }
                    catch { }
                }

                STEM.Sys.EventLog.WriteEntry("ConnectionType.Handshake", "Handshake completed with " + connection.RemoteAddress + ":" + port + ".", Sys.EventLog.EventLogEntryType.Information);
            }
            catch
            {
                if (connection.SessionID() == _ConnectionSessionID)
                {
                    connection.Close();
                }
            }
        }