示例#1
0
 protected override void Reconnect(Connection.Base connection)
 {
     if (connection != null)
     {
         CloseMonitor(connection.Remote);
     }
 }
示例#2
0
        protected void Close(Connection.Base connection)
        {
            if (connection != null)
            {
                if (connection is Connection.Tcp)
                {
                    lock (initializedConnections)
                    {
                        initializedConnections.Remove(connection as Connection.Tcp);
                    }
                }

                if (connection.Channel != ushort.MaxValue)
                {
                    lock (openedChannels)
                    {
                        Connection.Base[] connections;

                        if (openedChannels.TryGetValue(connection.Remote, out connections))
                        {
                            connections[connection.Channel] = null;
                        }

                        openedChannels.Remove(connection.Remote);
                    }
                }

                connection.Close();
            }
        }
示例#3
0
        protected override void Reconnect(Connection.Base connection)
        {
            if (state == State.RUNNING && connection != null && connection.AutoReconnect)
            {
                if (connection != null && CloseMonitor(connection.Remote))
                {
                    Connect();
                }
                else
                {
                    Type type = connection.GetType();

                    if (typeof(Connection.Tcp).IsAssignableFrom(type))
                    {
                        ConnectTcp(connection.Parameters);
                    }
                    else if (typeof(Connection.Udp).IsAssignableFrom(type))
                    {
                        if (monitors.TryGetValue(connection.Remote, out Connection.Tcp monitor))
                        {
                            ConnectUdp(monitor, connection.Parameters);
                        }
                        else
                        {
                            Debug.LogErrorFormat("No monitor channel with guid '{0}' to reconnect UDP channel {1}", connection.Remote, connection.Channel);
                        }
                    }
                }
            }
        }
示例#4
0
        protected void DisconnectionHandler(Connection.Base connection)
        {
            Close(connection);

            if (state == State.RUNNING)
            {
                Reconnect(connection);
            }
        }
示例#5
0
 protected abstract void Reconnect(Connection.Base connection);