2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
// Copyright (C) 2000,2001 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// 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, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
|
2008-10-27 00:53:29 +00:00
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
/*
|
|
|
|
|
* Imported MetaServer API implementation.
|
|
|
|
|
*/
|
|
|
|
|
#include "metaserverapi/MetaServerAPI.hpp"
|
|
|
|
|
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
#include "CommMetaClient.h"
|
|
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/globals.h"
|
2014-03-25 00:22:54 -04:00
|
|
|
#include "common/Monitors.h"
|
|
|
|
|
#include <varconf/config.h>
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <iostream>
|
2014-01-30 16:13:32 +01:00
|
|
|
#include <memory>
|
2014-03-25 00:22:54 -04:00
|
|
|
#include <vector>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2008-10-27 00:53:29 +00:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
using namespace boost::asio;
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
|
|
|
|
|
2004-08-27 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, server/CommSocket.h, server/CommIdleSocket.h:
Make constructors of some base classes protected.
* server/Account.cpp: Note a possible bug in the character
creation code.
* server/CommIdleSocket.cpp, server/CommIdleSocket.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommRemoteClient.cpp,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Clean up the Comm classes for consistancy and readability.
2004-08-28 00:58:01 +00:00
|
|
|
/// \brief Constructor for metaserver communication socket object.
|
|
|
|
|
///
|
|
|
|
|
/// @param svr Reference to the object that manages all socket communication.
|
2014-01-30 16:13:32 +01:00
|
|
|
CommMetaClient::CommMetaClient(io_service& ioService) :
|
|
|
|
|
mSocket(ioService, ip::udp::endpoint(ip::udp::v4(), 0)), mKeepaliveTimer(
|
|
|
|
|
ioService), mResolver(ioService), m_heartbeatTime(300)
|
2004-06-11 Al Riddoch <alriddoch@zepler.org>
* server/Restoration.h, server/CommUnixListener.h,
server/CommSocket.h, server/CommSocket.cpp,
server/CommServer.h, server/CommMetaClient.h,
server/CommMetaClient.cpp, server/CommListener.h,
server/CommListener.cpp, server/CommIdleSocket.h,
server/CommIdleSocket.cpp, rulesets/Area.h,
modules/WorldTime.h, common/OOGThing.h, common/OOGThing.cpp:
Get rid of some naughty stray implicit constructors.
2004-06-11 11:37:03 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
CommMetaClient::~CommMetaClient()
|
2003-10-12 Al Riddoch <alriddoch@zepler.org>
* server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/CommServer.cpp,
server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommClient.cpp, server/CommClient.h:
Add a new dispatch method to the socket interface, delaying
dispatch of incoming data until after it has been read, so that
a write timeout cannot occur during reading.
2003-10-12 19:16:52 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-27 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, server/CommSocket.h, server/CommIdleSocket.h:
Make constructors of some base classes protected.
* server/Account.cpp: Note a possible bug in the character
creation code.
* server/CommIdleSocket.cpp, server/CommIdleSocket.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommRemoteClient.cpp,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Clean up the Comm classes for consistancy and readability.
2004-08-28 00:58:01 +00:00
|
|
|
/// \brief Set the target address if the communication socket.
|
|
|
|
|
///
|
|
|
|
|
/// @param mserver String address of the metaserver,
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* client/BaseClient.cpp, client/BaseClient.h,,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, client/Py_CreatorClient.h,
client/client.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int CommMetaClient::setup(const std::string & mserver)
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
{
|
2008-10-27 00:53:29 +00:00
|
|
|
m_server = mserver;
|
2013-05-14 15:04:47 -04:00
|
|
|
|
|
|
|
|
/*
|
2014-03-25 00:22:54 -04:00
|
|
|
* Ensure attributes list is clear
|
2013-05-14 15:04:47 -04:00
|
|
|
*/
|
2014-03-25 00:22:54 -04:00
|
|
|
m_serverAttributes.clear();
|
2013-05-14 15:04:47 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get the heartbeat time
|
|
|
|
|
*/
|
|
|
|
|
readConfigItem("cyphesis","msheartbeat", m_heartbeatTime);
|
|
|
|
|
|
|
|
|
|
/*
|
2014-03-25 00:22:54 -04:00
|
|
|
* Update the attributes to include config + monitors
|
2013-05-14 15:04:47 -04:00
|
|
|
*/
|
2014-03-25 00:22:54 -04:00
|
|
|
updateAttributes();
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
ip::udp::resolver::query query(ip::udp::v4(), m_server, "8453");
|
|
|
|
|
mResolver.async_resolve(query,
|
|
|
|
|
[this](boost::system::error_code ec, ip::udp::resolver::iterator iterator ) {
|
2014-03-10 12:59:53 +01:00
|
|
|
if (!ec) {
|
|
|
|
|
mDestination = *iterator;
|
|
|
|
|
this->metaserverKeepalive();
|
|
|
|
|
this->do_receive();
|
|
|
|
|
this->keepalive();
|
|
|
|
|
}
|
2014-01-30 16:13:32 +01:00
|
|
|
});
|
|
|
|
|
|
2008-10-27 00:53:29 +00:00
|
|
|
return 0;
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
void CommMetaClient::do_receive()
|
|
|
|
|
{
|
2014-02-03 22:00:46 +01:00
|
|
|
mSocket.async_receive_from(buffer(mReadBuffer.data(), MAX_PACKET_BYTES), mDestination,
|
2014-01-30 16:13:32 +01:00
|
|
|
[this](boost::system::error_code ec, std::size_t length)
|
|
|
|
|
{
|
|
|
|
|
if (!ec)
|
|
|
|
|
{
|
|
|
|
|
this->metaserverReply(length);
|
|
|
|
|
}
|
|
|
|
|
this->do_receive();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommMetaClient::keepalive()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
mKeepaliveTimer.expires_from_now(
|
2014-02-03 22:00:46 +01:00
|
|
|
boost::posix_time::seconds(m_heartbeatTime));
|
2014-01-30 16:13:32 +01:00
|
|
|
|
|
|
|
|
mKeepaliveTimer.async_wait([this](boost::system::error_code ec)
|
|
|
|
|
{
|
|
|
|
|
if (!ec)
|
|
|
|
|
{
|
|
|
|
|
ip::udp::resolver::query query(ip::udp::v4(), m_server, "8453");
|
|
|
|
|
mResolver.async_resolve(query,
|
|
|
|
|
[this](boost::system::error_code ec, ip::udp::resolver::iterator iterator ) {
|
2014-02-01 18:40:21 +01:00
|
|
|
if (!ec) {
|
|
|
|
|
mDestination = *iterator;
|
|
|
|
|
this->metaserverKeepalive();
|
|
|
|
|
}
|
2014-01-30 16:13:32 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this->keepalive();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-27 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, server/CommSocket.h, server/CommIdleSocket.h:
Make constructors of some base classes protected.
* server/Account.cpp: Note a possible bug in the character
creation code.
* server/CommIdleSocket.cpp, server/CommIdleSocket.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommRemoteClient.cpp,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Clean up the Comm classes for consistancy and readability.
2004-08-28 00:58:01 +00:00
|
|
|
/// \brief Send a keepalive packet to the metaserver.
|
|
|
|
|
///
|
|
|
|
|
/// This should be called periodically to send a packet notifying the
|
|
|
|
|
/// metaserver that this server is still alive.
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
void CommMetaClient::metaserverKeepalive()
|
|
|
|
|
{
|
|
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
auto keep = std::make_shared<MetaServerPacket>();
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
keep->setPacketType(NMT_SERVERKEEPALIVE);
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
mSocket.async_send_to(buffer(keep->getBuffer().data(), keep->getSize()),
|
2014-01-30 16:13:32 +01:00
|
|
|
mDestination,
|
|
|
|
|
[this, keep](boost::system::error_code ec, std::size_t length)
|
|
|
|
|
{
|
|
|
|
|
if (!ec)
|
|
|
|
|
{
|
2014-03-25 00:22:54 -04:00
|
|
|
updateAttributes();
|
|
|
|
|
sendAllAttributes();
|
2014-01-30 16:13:32 +01:00
|
|
|
}
|
|
|
|
|
});
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-27 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, server/CommSocket.h, server/CommIdleSocket.h:
Make constructors of some base classes protected.
* server/Account.cpp: Note a possible bug in the character
creation code.
* server/CommIdleSocket.cpp, server/CommIdleSocket.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommRemoteClient.cpp,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Clean up the Comm classes for consistancy and readability.
2004-08-28 00:58:01 +00:00
|
|
|
/// \brief Read a reply from the metaserver.
|
|
|
|
|
///
|
|
|
|
|
/// Read the data sent by the metaserver. If the packet received is
|
|
|
|
|
/// a handshake, respond with the required response to verify that
|
|
|
|
|
/// we are alive.
|
2014-01-30 16:13:32 +01:00
|
|
|
void CommMetaClient::metaserverReply(size_t packet_size)
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
{
|
2003-04-22 22:01:28 +00:00
|
|
|
uint32_t handshake = 0, command = 0;
|
|
|
|
|
|
2013-05-14 15:04:47 -04:00
|
|
|
if ( packet_size < (std::streamsize)sizeof(command)) {
|
2003-08-23 20:40:39 +00:00
|
|
|
log(WARNING, "WARNING: Reply from metaserver too short");
|
2005-05-26 23:44:32 +00:00
|
|
|
return;
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
MetaServerPacket shake(mReadBuffer, packet_size);
|
2013-05-14 15:04:47 -04:00
|
|
|
|
|
|
|
|
if(shake.getPacketType() == NMT_HANDSHAKE )
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
{
|
2013-05-14 15:04:47 -04:00
|
|
|
handshake = shake.getIntData(4); // we know 4 bytes for type, and 4 for shake
|
2002-11-23 17:35:50 +00:00
|
|
|
debug(std::cout << "MetaServer contacted successfully."
|
|
|
|
|
<< std::endl << std::flush;);
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
auto servershake = std::make_shared<MetaServerPacket>();
|
|
|
|
|
servershake->setPacketType(NMT_SERVERSHAKE);
|
|
|
|
|
servershake->addPacketData(handshake);
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
|
|
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
mSocket.async_send_to(buffer(servershake->getBuffer().data(), servershake->getSize()),mDestination,
|
2014-02-01 18:40:21 +01:00
|
|
|
[this, servershake](boost::system::error_code ec, std::size_t length){});
|
2014-01-30 16:13:32 +01:00
|
|
|
|
2013-05-14 15:04:47 -04:00
|
|
|
|
|
|
|
|
}
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-27 Al Riddoch <alriddoch@zepler.org>
* common/BaseWorld.h, server/CommSocket.h, server/CommIdleSocket.h:
Make constructors of some base classes protected.
* server/Account.cpp: Note a possible bug in the character
creation code.
* server/CommIdleSocket.cpp, server/CommIdleSocket.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommRemoteClient.cpp,
server/CommSocket.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Clean up the Comm classes for consistancy and readability.
2004-08-28 00:58:01 +00:00
|
|
|
/// \brief Send a terminate packet to the metaserver.
|
|
|
|
|
///
|
|
|
|
|
/// This should be called to indicate that this server is going down,
|
|
|
|
|
/// and should no longer be listed.
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
void CommMetaClient::metaserverTerminate()
|
|
|
|
|
{
|
|
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
mKeepaliveTimer.cancel();
|
|
|
|
|
auto term = std::make_shared<MetaServerPacket>();
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2014-01-30 16:13:32 +01:00
|
|
|
term->setPacketType(NMT_TERMINATE);
|
2013-05-14 15:04:47 -04:00
|
|
|
|
2014-02-01 18:40:21 +01:00
|
|
|
//Do a blocking send as we're calling this when we're shutting down.
|
2014-02-03 22:00:46 +01:00
|
|
|
mSocket.send_to(buffer(term->getBuffer().data(), term->getSize()), mDestination);
|
2013-05-14 15:04:47 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommMetaClient::metaserverAttribute(const std::string& k, const std::string & v )
|
|
|
|
|
{
|
2014-01-30 16:13:32 +01:00
|
|
|
auto m = std::make_shared<MetaServerPacket>();
|
|
|
|
|
|
|
|
|
|
m->setPacketType(NMT_SERVERATTR);
|
|
|
|
|
m->addPacketData(k.length());
|
|
|
|
|
m->addPacketData(v.length());
|
|
|
|
|
m->addPacketData(k);
|
|
|
|
|
m->addPacketData(v);
|
|
|
|
|
|
|
|
|
|
|
2014-02-03 22:00:46 +01:00
|
|
|
mSocket.async_send_to(buffer(m->getBuffer().data(), m->getSize()), mDestination,
|
2014-02-01 18:40:21 +01:00
|
|
|
[this, m](boost::system::error_code ec, std::size_t length){});
|
2012-07-31 20:21:58 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-25 00:22:54 -04:00
|
|
|
/// \brief Read attributes from config and monitor
|
|
|
|
|
///
|
|
|
|
|
///
|
|
|
|
|
void CommMetaClient::updateAttributes()
|
|
|
|
|
{
|
|
|
|
|
std::string mstats;
|
|
|
|
|
std::vector<std::string> fields;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get pipe separate list from the config about monitored variables
|
|
|
|
|
*/
|
|
|
|
|
readConfigItem("cyphesis", "metastats", mstats);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Split on | character
|
|
|
|
|
*/
|
|
|
|
|
boost::algorithm::split( fields, mstats, boost::algorithm::is_any_of( "|" ) );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Iterate fields and snag from the monitor, if it exists;
|
|
|
|
|
*/
|
|
|
|
|
for (auto& v : fields)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream ss;
|
2014-03-25 13:39:38 -04:00
|
|
|
if ( Monitors::instance()->readVariable(v,ss) == 0 )
|
2014-03-25 00:22:54 -04:00
|
|
|
{
|
|
|
|
|
std::string tmp = ss.str();
|
|
|
|
|
boost::algorithm::trim(tmp);
|
|
|
|
|
m_serverAttributes[v] = tmp;
|
|
|
|
|
} else {
|
|
|
|
|
ss << "WARNING: [cyphesis].metastats item [" << v << "] is not a monitored variable";
|
|
|
|
|
log(WARNING,ss.str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get the configuration values to send
|
|
|
|
|
* In the event that a user has specified a variable that matches
|
|
|
|
|
* the name of a monitor, the configured item will have priority.
|
|
|
|
|
*/
|
|
|
|
|
const varconf::sec_map& c = global_conf->getSection("metaattributes");
|
|
|
|
|
for (auto& kv : c)
|
|
|
|
|
{
|
|
|
|
|
std::string s = kv.second;
|
|
|
|
|
boost::algorithm::trim(s);
|
|
|
|
|
m_serverAttributes[kv.first] = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Utility to send all attributes to the metaserver
|
|
|
|
|
///
|
|
|
|
|
void CommMetaClient::sendAllAttributes()
|
|
|
|
|
{
|
|
|
|
|
for (auto& kv : m_serverAttributes) {
|
|
|
|
|
metaserverAttribute(kv.first, kv.second);
|
|
|
|
|
}
|
|
|
|
|
}
|