#include <ArServerHandlerMap.h>
Public Types | |
enum | DataToSend { LINES = 1, POINTS = 2, BOTH = 3 } |
Public Member Functions | |
ArServerHandlerMap (ArServerBase *server, ArMap *arMap=NULL, DataToSend dataToSend=BOTH) | |
Constructor. | |
DataToSend | getDataToSend (void) |
Gets which kind of data we send. | |
ArMap * | getMap (void) |
Gets the map object this is using. | |
bool | loadMap (const char *mapFile) |
Loads the map from a file. | |
void | serverGetGoals (ArServerClient *client, ArNetPacket *packet) |
The command that'll get the goals. | |
void | serverGetMap (ArServerClient *client, ArNetPacket *packet) |
The command that'll get the map itself. | |
void | serverGetMapBinary (ArServerClient *client, ArNetPacket *packet) |
The command that gets the map, with the data in binary format for improved performance. | |
void | serverGetMapName (ArServerClient *client, ArNetPacket *packet) |
The command that gets the map name. | |
void | setDataToSend (DataToSend dataToSend) |
Sets which kind of data we send. | |
void | useMap (ArMap *mapObj, bool takeOwnershipOfMap=false) |
Uses a map already loaded. | |
virtual | ~ArServerHandlerMap () |
Destructor. | |
Protected Member Functions | |
void | mapChanged (void) |
bool | processFile (void) |
void | writeLinesToClient (int lineCount, std::vector< ArLineSegment > *points, ArServerClient *client) |
void | writeMapToClient (const char *line, ArServerClient *client) |
void | writePointsToClient (int pointCount, std::vector< ArPose > *points, ArServerClient *client) |
Protected Attributes | |
bool | myAlreadyLoaded |
DataToSend | myDataToSend |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetGoalsCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapBinaryCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapCB |
ArFunctor2C< ArServerHandlerMap, ArServerClient *, ArNetPacket * > | myGetMapNameCB |
char | myLastMapFile [1024] |
stat | myLastMapFileStat |
ArMap * | myMap |
ArFunctorC< ArServerHandlerMap > | myMapChangedCB |
char | myMapFileName [512] |
std::string | myMapName |
bool | myOwnMap |
ArRetFunctorC< bool, ArServerHandlerMap > | myProcessFileCB |
ArServerBase * | myServer |
ArServerHandlerMap * | myServerHandlerMap |
A map can be provided from an ArMap object, or else the filename can be given in the global ArConfig object (see Aria::getConfig()) as "Map" in the "Files" section. This handler can also be configured to only send "point" data, "line" data, or both kinds of data from the map.
This service accepts the following data requests:
getMapName
getMap
getGoals
getMapBinary
The following data types will also be broadcast to all clients to indicate certain events:
mapUpdated
goalsUpdated
The getMapName
request replies with a packet containing a NULL-terminated string containing the filename of the map, or an empty string ("") if there is no map.
The getMap
request replies with a packet containing the map as it appears in the map file (see the documentation for ArMap for the file format).
The getGoals
request replies with a series of NULL-terminated strings containing the names of the Goal objects in the map.
The getMapBinary
request replies with the map headers and objects list (see ArMap for map file format) as text, but supplies point "DATA" and/or "LINES" as an undelimited sequence of 2-byte integers. (In the case of point data, each pair of integers is a point; for lines, each sequence of four integers defines a line). This binary representation of data is more compact than the ASCII text representation.
The mapUpdated
packet is sent to all connected clients whenever a new map is loaded or the map is changed. The packet contains no data; the new map can be downloaded using one of the above requests.
The goalsUpdated
packet is sent to all connected clients whenever the list of Goal objects changes in the map or a new map is loaded. The packet contains no data; the new list of goals can be downloaded using getGoals
, or by downloading the entire map.
Definition at line 88 of file ArServerHandlerMap.h.
|
Definition at line 91 of file ArServerHandlerMap.h. |
|
Constructor.
Definition at line 45 of file ArServerHandlerMap.cpp. References ArServerBase::addData(), ArMap::addMapChangedCB(), ArConfig::addParam(), ArConfig::addProcessFileCB(), Aria::getConfig(), ArMap::getFileName(), myAlreadyLoaded, myGetGoalsCB, myGetMapBinaryCB, myGetMapCB, myGetMapNameCB, myMap, myMapChangedCB, myMapFileName, myOwnMap, myProcessFileCB, myServer, setDataToSend(), ArFunctor::setName(), and ArConfig::setSectionComment(). |
|
Destructor.
Definition at line 110 of file ArServerHandlerMap.cpp. |
|
Gets which kind of data we send.
Definition at line 119 of file ArServerHandlerMap.h. References myDataToSend. |
|
Gets the map object this is using.
Definition at line 154 of file ArServerHandlerMap.cpp. References myMap. |
|
Loads the map from a file.
Definition at line 115 of file ArServerHandlerMap.cpp. References ArServerBase::broadcastPacketTcp(), myMap, myMapName, myOwnMap, myServer, and ArMap::readFile(). Referenced by processFile(). |
|
Definition at line 511 of file ArServerHandlerMap.cpp. References ArServerBase::broadcastPacketTcp(), ArMap::getFileName(), myMap, myMapFileName, and myServer. |
|
For internal use only.
Definition at line 520 of file ArServerHandlerMap.cpp. References loadMap(), ArLog::log(), myAlreadyLoaded, myLastMapFile, myLastMapFileStat, and myMapFileName. |
|
The command that'll get the goals.
For internal use only.
Definition at line 484 of file ArServerHandlerMap.cpp. References client, ArMap::getMapObjects(), ArMapObject::getName(), ArMapObject::getType(), myMap, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf(). |
|
The command that'll get the map itself.
For internal use only.
Definition at line 376 of file ArServerHandlerMap.cpp. References client, ArMap::lock(), ArLog::log(), myMap, ArClientBase::sendPacketTcp(), ArMap::unlock(), writeMapToClient(), and ArMap::writeToFunctor(). |
|
The command that gets the map, with the data in binary format for improved performance.
Definition at line 410 of file ArServerHandlerMap.cpp. References BOTH, client, ArMap::getLines(), LINES, ArMap::lock(), ArLog::log(), myDataToSend, myMap, POINTS, ArClientBase::sendPacketTcp(), ArMap::unlock(), writeLinesToClient(), ArMap::writeLinesToFunctor(), writeMapToClient(), ArMap::writeObjectsToFunctor(), writePointsToClient(), and ArMap::writePointsToFunctor(). |
|
The command that gets the map name.
For internal use only.
Definition at line 160 of file ArServerHandlerMap.cpp. References client, ArMap::getFileName(), myMap, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf(). |
|
Sets which kind of data we send.
Definition at line 116 of file ArServerHandlerMap.h. References myDataToSend. Referenced by ArServerHandlerMap(). |
|
Uses a map already loaded.
Definition at line 137 of file ArServerHandlerMap.cpp. References ArServerBase::broadcastPacketTcp(), ArMap::getFileName(), myMap, myMapName, myOwnMap, and myServer. |
|
For internal use only.
Definition at line 278 of file ArServerHandlerMap.cpp. References ArBasePacket::byte4ToBuf(), client, ArNetPacket::empty(), ArLog::log(), and ArClientBase::sendPacketTcp(). Referenced by serverGetMapBinary(). |
|
For internal use only.
Definition at line 177 of file ArServerHandlerMap.cpp. References client, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf(). Referenced by serverGetMap(), and serverGetMapBinary(). |
|
For internal use only.
Definition at line 186 of file ArServerHandlerMap.cpp. References ArBasePacket::byte4ToBuf(), client, ArNetPacket::empty(), ArLog::log(), and ArClientBase::sendPacketTcp(). Referenced by serverGetMapBinary(). |
|
Definition at line 141 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(), and processFile(). |
|
Definition at line 137 of file ArServerHandlerMap.h. Referenced by getDataToSend(), serverGetMapBinary(), and setDataToSend(). |
|
Definition at line 152 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 150 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 148 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 146 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 143 of file ArServerHandlerMap.h. Referenced by processFile(). |
|
Definition at line 144 of file ArServerHandlerMap.h. Referenced by processFile(). |
|
Definition at line 138 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(), getMap(), loadMap(), mapChanged(), serverGetGoals(), serverGetMap(), serverGetMapBinary(), serverGetMapName(), and useMap(). |
|
Definition at line 154 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 142 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(), mapChanged(), and processFile(). |
|
Definition at line 139 of file ArServerHandlerMap.h. |
|
Definition at line 136 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(), loadMap(), and useMap(). |
|
Definition at line 153 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(). |
|
Definition at line 135 of file ArServerHandlerMap.h. Referenced by ArServerHandlerMap(), loadMap(), mapChanged(), and useMap(). |
|
Definition at line 140 of file ArServerHandlerMap.h. |