Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

void CUser::Reconnect ( void   ) 

Reconnect

Reconnects the user to an IRC server.

Definition at line 630 of file User.cpp.

References CCore::GetDefaultVHost(), GetIdent(), GetIPv6(), GetPort(), GetServer(), GetSSL(), GetUsername(), GetVHost(), CIRCConnection::Kill(), CCore::Log(), CCore::LogUser(), m_IRC, m_LastReconnect, m_Name, ScheduleReconnect(), CCore::SetIdent(), and SetIRCConnection().

                          {
      const char *Server;
      int Port;
      safe_box_t IRCBox = NULL;

      if (m_IRC != NULL) {
            m_IRC->Kill("Reconnecting.");

            SetIRCConnection(NULL);
      }

      Server = GetServer();
      Port = GetPort();

      if (Server == NULL || Port == 0) {
            ScheduleReconnect(60);

            return;
      }

      if (GetIPv6()) {
            g_Bouncer->LogUser(this, "Trying to reconnect to [%s]:%d for user %s", Server, Port, m_Name);
      } else {
            g_Bouncer->LogUser(this, "Trying to reconnect to %s:%d for user %s", Server, Port, m_Name);
      }

      m_LastReconnect = g_CurrentTime;

      const char *BindIp = GetVHost();

      if (BindIp == NULL || BindIp[0] == '\0') {
            BindIp = g_Bouncer->GetDefaultVHost();
      }

      if (BindIp != NULL && BindIp[0] == '\0') {
            BindIp = NULL;
      }

      if (GetIdent() != NULL) {
            g_Bouncer->SetIdent(GetIdent());
      } else {
            g_Bouncer->SetIdent(m_Name);
      }

      if (GetBox() != NULL) {
            IRCBox = safe_put_box(GetBox(), "IRC");
      }

      CIRCConnection *Connection = new CIRCConnection(Server, Port, this, IRCBox, BindIp, GetSSL(), GetIPv6() ? AF_INET6 : AF_INET);

      CHECK_ALLOC_RESULT(Connection, new) {
            return;
      } CHECK_ALLOC_RESULT_END;

      SetIRCConnection(Connection);

      g_Bouncer->Log("Connection initialized for user %s. Waiting for response...", GetUsername());

      RescheduleReconnectTimer();
}


Generated by  Doxygen 1.6.0   Back to index