Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 07, 2012
@Anubisss OMG, this not needed.
Signed-off-by: Anubisss <anubisss210@gmail.com>
806311f
@Anubisss Implement a RealmdManager class and command info.
Signed-off-by: Anubisss <anubisss210@gmail.com>
7c43df4
View
30 src/server/authserver/CLI/Commands/Impl.cpp
@@ -27,8 +27,11 @@
#include "Command.h"
#include <iostream>
+#include <ctime>
-#include <ace/Thread_Manager.h>
+#include "SystemConfig.h"
+#include "Util.h"
+#include "RealmdManager.h"
/**
* @brief This command is just an example and also can be used for debugging.
@@ -41,12 +44,34 @@ class Command_Test : public Command
/* virtual */ void Execute()
{
- ACE_Thread_Manager::instance()->wait(&ACE_Time_Value((time_t)10));
std::cout << "Hello World!" << std::endl;
}
};
/**
+ * @brief Print some info about the daemon.
+ * @details Print some info about the daemon compilation, like:
+ "TrinityCore rev. 2012-03-04 18:21:08 +0100 (f5730e82ced8+) (Unix, DEBUG)"@n
+ Print the daemon's uptime, like: "Uptime: 4 Minute(s) 32 Second(s).".
+ * @todo Print active connections.@n
+ * Print max active connections.@n
+ * Print update time diff.@n
+ * Print max update time diff.@n
+ */
+
+class Command_Info : public Command
+{
+public:
+ Command_Info() : Command("info") {}
+
+ /* virtual */ void Execute()
+ {
+ std::cout << _FULLVERSION << std::endl
+ << "Uptime: " << secsToTimeString(sRealmdManager->GetUpTime()) << std::endl;
+ }
+};
+
+/**
* @brief This method allocates resources for the implemented commands.
* Function called in CLITask's constructor.
* @see CLITask::CLITask()
@@ -55,4 +80,5 @@ class Command_Test : public Command
void Impl_RegisterCommands()
{
new Command_Test();
+ new Command_Info();
}
View
3 src/server/authserver/CMakeLists.txt
@@ -12,6 +12,7 @@
file(GLOB_RECURSE sources_authentication Authentication/*.cpp Authentication/*.h)
file(GLOB_RECURSE sources_cli CLI/*.cpp CLI/*.h)
+file(GLOB_RECURSE sources_realmd_manager RealmdManager/*.cpp RealmdManager/*.h)
file(GLOB_RECURSE sources_realms Realms/*.cpp Realms/*.h)
file(GLOB_RECURSE sources_server Server/*.cpp Server/*.h)
file(GLOB sources_localdir *.cpp *.h)
@@ -31,6 +32,7 @@ set(authserver_SRCS
${authserver_SRCS}
${sources_authentication}
${sources_cli}
+ ${sources_realmd_manager}
${sources_realms}
${sources_server}
${sources_localdir}
@@ -60,6 +62,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/CLI
${CMAKE_CURRENT_SOURCE_DIR}/CLI/Commands
${CMAKE_CURRENT_SOURCE_DIR}/Realms
+ ${CMAKE_CURRENT_SOURCE_DIR}/RealmdManager
${CMAKE_CURRENT_SOURCE_DIR}/Server
${ACE_INCLUDE_DIR}
${MYSQL_INCLUDE_DIR}
View
3 src/server/authserver/Main.cpp
@@ -33,6 +33,7 @@
#include "RealmList.h"
#include "RealmAcceptor.h"
#include "CLITask.h"
+#include "RealmdManager.h"
#ifndef _TRINITY_REALM_CONFIG
# define _TRINITY_REALM_CONFIG "authserver.conf"
@@ -92,6 +93,8 @@ extern int main(int argc, char **argv)
++c;
}
+ sRealmdManager; // init this singleton
+
if (!ConfigMgr::Load(cfg_file))
{
sLog->outError("Invalid or missing configuration file : %s", cfg_file);
View
67 src/server/authserver/RealmdManager/RealmdManager.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Declaration of class RealmdManager.
+ * @author Anubisss <anubisss210@gmail.com>
+ */
+
+#ifndef __REALMD_MANAGER_H__
+#define __REALMD_MANAGER_H__
+
+#include <ace/Singleton.h>
+#include <ace/Null_Mutex.h>
+
+/**
+ * @brief Singleton which manages global realmd related things.
+ */
+
+class RealmdManager
+{
+public:
+ /**
+ * @brief Initialization of the class.
+ * @details Set the start time.
+ * @see _startTime
+ */
+ RealmdManager()
+ {
+ _startTime = time(NULL);
+ }
+
+ /**
+ * @brief Tells how much uptime the daemon has.
+ * @details Algorithm: nowInUnixTime - _startTime
+ * @see _startTime
+ */
+ time_t GetUpTime() const { return time(NULL) - _startTime; }
+
+ /**
+ * @brief When the daemon started in UNIX timestamp.
+ */
+private:
+ time_t _startTime;
+};
+
+/**
+ * @brief Macro to access that class.
+ */
+#define sRealmdManager ACE_Singleton<RealmdManager, ACE_Null_Mutex>::instance()
+
+#endif /* __REALMD_MANAGER_H__ */

No commit comments for this range

Something went wrong with that request. Please try again.