Planeshift
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

NetworkManager Class Reference

Handle all network messages inn and out of the NPC Client. More...

#include <networkmgr.h>

List of all members.

Public Member Functions

void Authenticate (csString &host, int port, csString &user, csString &pass)
void CheckCommandsOverrun (size_t neededSize)
 Checks if the npc command message could overrun if the neededSize is tried to be added.
void DequeueDRData (NPC *npc)
 Call to remove queued dr updates when entities are removed/deleted.
void Disconnect ()
const char * GetCommonString (uint32_t cstr_id)
 Convert a common string id into the corresponding string.
uint32_t GetCommonStringID (const char *string)
 Convert a string into a common string id.
csStringHashReversible * GetMsgStrings ()
 Get the message string table.
virtual void HandleMessage (MsgEntry *pMsg)
 Handle all messages from server and send them to specefic Handle functions for each message type.
bool IsReady ()
 NetworkManager (MsgHandler *mh, psNetConnection *conn, iEngine *engine)
 Construct the network manager.
void PrepareCommandMessage ()
 Prepare a new command message allow for queuing of new commands.
void QueueAnimationCommand (gemNPCActor *npc, const csString &cmd)
 Send an animation command to server.
void QueueAssessCommand (gemNPCActor *entity, gemNPCObject *target, const csString &physicalAssessmentPerception, const csString &magicalAssessmentPerception, const csString &overallAssessmentPerception)
 Send a command to do an assessment.
void QueueAttackCommand (gemNPCActor *attacker, gemNPCActor *target, const char *stance, const char *attack_type)
 Queue an Attack Command for an NPC to the server.
void QueueBusyCommand (gemNPCActor *entity, bool busy)
 Send a command to change the busy state.
void QueueCastCommand (gemNPCActor *entity, gemNPCObject *target, const csString &spell, float kFactor)
 Send a command to start cast a spell.
void QueueControlCommand (gemNPCActor *controllingEntity, gemNPCActor *controlledEntity)
 Send a command start controll an entity.
void QueueDeleteNPCCommand (NPC *npcx)
 Send a command to delete a npc.
void QueueDequipCommand (gemNPCActor *entity, csString slot)
 Send a command to dequip an equipment.
void QueueDRData (NPC *npc)
 Queue the NPC for an DR Update to the server.
void QueueDRData2 (NPC *npc)
 Queue the NPC for an DR Update to the server.
void QueueDropCommand (gemNPCActor *entity, csString slot)
 Send a command to drop the content of a slot.
void QueueEmoteCommand (gemNPCActor *npc, gemNPCObject *target, const csString &cmd)
 Send an emote command to server.
void QueueEquipCommand (gemNPCActor *entity, csString item, csString slot, int count)
 Send a command to equip an equipment.
void QueueLootCommand (gemNPCActor *entity, EID targetEID, const csString &type)
 Send a command to loot selected target.
void QueuePickupCommand (gemNPCActor *entity, gemNPCObject *item, int count)
 Queue a command to pickup a item.
void QueueResurrectCommand (csVector3 where, float rot, iSector *sector, PID character_id)
 Send a command to resurrect.
void QueueScriptCommand (gemNPCActor *npc, gemNPCObject *target, const csString &scriptName)
 Send a script command to server.
void QueueSequenceCommand (csString name, int cmd, int count)
 Send a command to start a sequence.
void QueueSitCommand (gemNPCActor *npc, gemNPCObject *target, bool sit)
 Send a sit command to server.
void QueueSpawnBuildingCommand (gemNPCActor *spawner, csVector3 where, iSector *sector, const char *buildingName, int tribeID, bool pickupable)
 Send a spawn building command to server.
void QueueSpawnCommand (gemNPCActor *mother, gemNPCActor *father, const csString &tribeMemberType)
 Send a spawn command to server.
void QueueSystemInfoCommand (uint32_t clientNum, const char *reply,...)
 Send an system info command to the client.
void QueueTalkCommand (gemNPCActor *speaker, gemNPCActor *target, psNPCCommandsMessage::PerceptionTalkType talkType, bool publicTalk, const char *text)
 Queue a talk command to the server.
void QueueTemporarilyImperviousCommand (gemNPCActor *entity, bool impervious)
 Send a command to change the temporarily impervious status.
void QueueTransferCommand (gemNPCActor *entity, csString item, int count, csString target)
 Send a command to transfere an item between two entities.
void QueueUnbuildCommand (gemNPCActor *unbuilder, gemNPCItem *building)
 Send a unbuild command to server.
void QueueVisibilityCommand (gemNPCActor *entity, bool status)
 Queue a change in visibility.
void QueueWorkCommand (gemNPCActor *entity, const csString &type, const csString &resource)
 Send a command to start working.
void ReAuthenticate ()
 Reauthenicate with the server.
void ReConnect ()
 Reconnect to the server server.
void SendAllCommands (bool final=false)
 Send the queued commands.
void SendConsoleCommand (const char *cmd)
 Send a console command.
virtual ~NetworkManager ()
 Destructor.

Public Attributes

bool reconnect
 Set to true if reconnect should be done.

Protected Member Functions

void HandleActor (MsgEntry *msg)
 Handle an actor from server.
void HandleAllEntities (MsgEntry *message)
 Handle list of all entities from server.
void HandleConsoleCommand (MsgEntry *me)
void HandleDisconnect (MsgEntry *msg)
 Handle command to disconnect from server.
void HandleHiredNPCScript (MsgEntry *me)
 Handle Hired npc script from server.
void HandleItem (MsgEntry *me)
 Handle a new item from server.
void HandleLocation (MsgEntry *me)
 Handle location changes from server.
bool HandleMapList (MsgEntry *msg)
 Handle the map list received from server.
void HandleNewNpc (MsgEntry *msg)
 Handle information from server about NPCs to use.
void HandleNpcDeleted (MsgEntry *msg)
 Handle information from server about deleted NPC.
bool HandleNPCList (MsgEntry *msg)
 Handle a list of npcs received from server.
void HandleNPCWorkDone (MsgEntry *msg)
 Handle information from server that work is done.
void HandleObjectRemoval (MsgEntry *me)
 Handle removal of an object from server.
void HandlePathNetwork (MsgEntry *me)
 Handle changes to path network from server.
void HandlePerceptions (MsgEntry *msg)
 Handle perceptions from the server.
void HandlePersistMessage (MsgEntry *msg)
 Handle new entities from server.
void HandlePositionUpdates (MsgEntry *msg)
 Handle update update of positions from server.
void HandleRaceList (MsgEntry *me)
 Handle list of races from server.
void HandleTimeUpdate (MsgEntry *msg)
 Handle time updates from server.
void RequestAllObjects ()
 Number of command messages queued.

Protected Attributes

int cmd_count
 Entities queued for sending of DR.
csHash< NPC *, PID > cmd_dr_outbound
bool connected
psNetConnectionconnection
csString host
MsgHandlermsghandler
psNPCCommandsMessageoutbound
csString password
int port
bool ready
csString user

Detailed Description

Handle all network messages inn and out of the NPC Client.

Definition at line 56 of file networkmgr.h.


Constructor & Destructor Documentation

NetworkManager::NetworkManager ( MsgHandler mh,
psNetConnection conn,
iEngine *  engine 
)

Construct the network manager.

virtual NetworkManager::~NetworkManager ( ) [virtual]

Destructor.


Member Function Documentation

void NetworkManager::Authenticate ( csString &  host,
int  port,
csString &  user,
csString &  pass 
)
void NetworkManager::CheckCommandsOverrun ( size_t  neededSize)

Checks if the npc command message could overrun if the neededSize is tried to be added.

Automatically sends the message in case it could overrun.

Parameters:
neededSizeThe size of data we are going to attempt to add to the npc commands message.
void NetworkManager::DequeueDRData ( NPC npc)

Call to remove queued dr updates when entities are removed/deleted.

void NetworkManager::Disconnect ( )
const char* NetworkManager::GetCommonString ( uint32_t  cstr_id)

Convert a common string id into the corresponding string.

uint32_t NetworkManager::GetCommonStringID ( const char *  string)

Convert a string into a common string id.

csStringHashReversible* NetworkManager::GetMsgStrings ( )

Get the message string table.

void NetworkManager::HandleActor ( MsgEntry msg) [protected]

Handle an actor from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleAllEntities ( MsgEntry message) [protected]

Handle list of all entities from server.

Parameters:
messageThe undecoded message to handle.
void NetworkManager::HandleConsoleCommand ( MsgEntry me) [protected]
Parameters:
meThe undecoded message to handle.
void NetworkManager::HandleDisconnect ( MsgEntry msg) [protected]

Handle command to disconnect from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleHiredNPCScript ( MsgEntry me) [protected]

Handle Hired npc script from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleItem ( MsgEntry me) [protected]

Handle a new item from server.

Parameters:
meThe undecoded message to handle.
void NetworkManager::HandleLocation ( MsgEntry me) [protected]

Handle location changes from server.

Parameters:
meThe undecoded message to handle.
bool NetworkManager::HandleMapList ( MsgEntry msg) [protected]

Handle the map list received from server.

Parameters:
msgThe undecoded message to handle.
virtual void NetworkManager::HandleMessage ( MsgEntry pMsg) [virtual]

Handle all messages from server and send them to specefic Handle functions for each message type.

Parameters:
pMsgThe undecoded message to handle.

Implements psClientNetSubscriber.

void NetworkManager::HandleNewNpc ( MsgEntry msg) [protected]

Handle information from server about NPCs to use.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleNpcDeleted ( MsgEntry msg) [protected]

Handle information from server about deleted NPC.

Parameters:
msgThe undecoded message to handle.
bool NetworkManager::HandleNPCList ( MsgEntry msg) [protected]

Handle a list of npcs received from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleNPCWorkDone ( MsgEntry msg) [protected]

Handle information from server that work is done.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleObjectRemoval ( MsgEntry me) [protected]

Handle removal of an object from server.

Parameters:
meThe undecoded message to handle.
void NetworkManager::HandlePathNetwork ( MsgEntry me) [protected]

Handle changes to path network from server.

Parameters:
meThe undecoded message to handle.
void NetworkManager::HandlePerceptions ( MsgEntry msg) [protected]

Handle perceptions from the server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandlePersistMessage ( MsgEntry msg) [protected]

Handle new entities from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandlePositionUpdates ( MsgEntry msg) [protected]

Handle update update of positions from server.

Parameters:
msgThe undecoded message to handle.
void NetworkManager::HandleRaceList ( MsgEntry me) [protected]

Handle list of races from server.

Parameters:
meThe undecoded message to handle.
void NetworkManager::HandleTimeUpdate ( MsgEntry msg) [protected]

Handle time updates from server.

Parameters:
msgThe undecoded message to handle.
bool NetworkManager::IsReady ( ) [inline]

Definition at line 227 of file networkmgr.h.

void NetworkManager::PrepareCommandMessage ( )

Prepare a new command message allow for queuing of new commands.

void NetworkManager::QueueAnimationCommand ( gemNPCActor npc,
const csString &  cmd 
)

Send an animation command to server.

Parameters:
npcThe npc that has an animation
cmdThe animation
void NetworkManager::QueueAssessCommand ( gemNPCActor entity,
gemNPCObject target,
const csString &  physicalAssessmentPerception,
const csString &  magicalAssessmentPerception,
const csString &  overallAssessmentPerception 
)

Send a command to do an assessment.

void NetworkManager::QueueAttackCommand ( gemNPCActor attacker,
gemNPCActor target,
const char *  stance,
const char *  attack_type 
)

Queue an Attack Command for an NPC to the server.

Parameters:
attackerThe NPC that will attack
targetThe target for the NPC or NULL to stop attack
stanceThe stance to be used
void NetworkManager::QueueBusyCommand ( gemNPCActor entity,
bool  busy 
)

Send a command to change the busy state.

void NetworkManager::QueueCastCommand ( gemNPCActor entity,
gemNPCObject target,
const csString &  spell,
float  kFactor 
)

Send a command to start cast a spell.

void NetworkManager::QueueControlCommand ( gemNPCActor controllingEntity,
gemNPCActor controlledEntity 
)

Send a command start controll an entity.

void NetworkManager::QueueDeleteNPCCommand ( NPC npcx)

Send a command to delete a npc.

void NetworkManager::QueueDequipCommand ( gemNPCActor entity,
csString  slot 
)

Send a command to dequip an equipment.

void NetworkManager::QueueDRData ( NPC npc)

Queue the NPC for an DR Update to the server.

Can be called multiple times. If in queue already nothing will be added.

Parameters:
npcQueue DR data for this NPC.
void NetworkManager::QueueDRData2 ( NPC npc)

Queue the NPC for an DR Update to the server.

Can be called multiple times. If in queue already nothing will be added.

Parameters:
npcQueue DR data for this NPC.
void NetworkManager::QueueDropCommand ( gemNPCActor entity,
csString  slot 
)

Send a command to drop the content of a slot.

void NetworkManager::QueueEmoteCommand ( gemNPCActor npc,
gemNPCObject target,
const csString &  cmd 
)

Send an emote command to server.

Parameters:
npcThe npc that has an emotion
targetThe current target of then npc
cmdThe emotion
void NetworkManager::QueueEquipCommand ( gemNPCActor entity,
csString  item,
csString  slot,
int  count 
)

Send a command to equip an equipment.

void NetworkManager::QueueLootCommand ( gemNPCActor entity,
EID  targetEID,
const csString &  type 
)

Send a command to loot selected target.

void NetworkManager::QueuePickupCommand ( gemNPCActor entity,
gemNPCObject item,
int  count 
)

Queue a command to pickup a item.

Parameters:
entityThe entity that should pick up a item.
itemThe item to pick up.
countThe number of items to pick up of a stack.
void NetworkManager::QueueResurrectCommand ( csVector3  where,
float  rot,
iSector *  sector,
PID  character_id 
)

Send a command to resurrect.

void NetworkManager::QueueScriptCommand ( gemNPCActor npc,
gemNPCObject target,
const csString &  scriptName 
)

Send a script command to server.

Parameters:
npcThe npc that sit/stand
targetThe current target of then npc
scriptNameThe name of the progression script to run at server
void NetworkManager::QueueSequenceCommand ( csString  name,
int  cmd,
int  count 
)

Send a command to start a sequence.

void NetworkManager::QueueSitCommand ( gemNPCActor npc,
gemNPCObject target,
bool  sit 
)

Send a sit command to server.

Parameters:
npcThe npc that sit/stand
targetThe current target of then npc
sitTrue if sitting, false if standing
void NetworkManager::QueueSpawnBuildingCommand ( gemNPCActor spawner,
csVector3  where,
iSector *  sector,
const char *  buildingName,
int  tribeID,
bool  pickupable 
)

Send a spawn building command to server.

Parameters:
spawnerThe entity that spawned the building
whereContaining the desired location
sectorThe sector in which we want a spawn.
buildingNameThe name of the building. Or more exactly... of the mesh for it.
tribeIDThe owner of this building
pickupableShould the building be possible to pick up
void NetworkManager::QueueSpawnCommand ( gemNPCActor mother,
gemNPCActor father,
const csString &  tribeMemberType 
)

Send a spawn command to server.

Parameters:
motherThe mother of the spawn
fatherIf the father is known point to the father, use mother if unknow.
tribeMemberTypeWhat type of tribe member is this.
void NetworkManager::QueueSystemInfoCommand ( uint32_t  clientNum,
const char *  reply,
  ... 
)

Send an system info command to the client.

Parameters:
clientNumThe client that should receive the system info.
replyThe reply to send back.
void NetworkManager::QueueTalkCommand ( gemNPCActor speaker,
gemNPCActor target,
psNPCCommandsMessage::PerceptionTalkType  talkType,
bool  publicTalk,
const char *  text 
)

Queue a talk command to the server.

The speaker will send a talk event say/action to target or nearby targets.

Parameters:
speakerThe npc that speaks.
targetThe current target.
talkTypeWhat kind of talk is this.
publicTalkTrue if this should be published. False will be a wisper.
textThe text to talk.
void NetworkManager::QueueTemporarilyImperviousCommand ( gemNPCActor entity,
bool  impervious 
)

Send a command to change the temporarily impervious status.

'

Parameters:
entityThe entity to change.
imperviousSet to true if temporarily impervious should be turned on.
void NetworkManager::QueueTransferCommand ( gemNPCActor entity,
csString  item,
int  count,
csString  target 
)

Send a command to transfere an item between two entities.

void NetworkManager::QueueUnbuildCommand ( gemNPCActor unbuilder,
gemNPCItem building 
)

Send a unbuild command to server.

Parameters:
unbuilderThe entity that unbuild the building
buildingThe building.
void NetworkManager::QueueVisibilityCommand ( gemNPCActor entity,
bool  status 
)

Queue a change in visibility.

Parameters:
entityThe entity to change visibility.
statusThe new visibility status. True or False.
void NetworkManager::QueueWorkCommand ( gemNPCActor entity,
const csString &  type,
const csString &  resource 
)

Send a command to start working.

void NetworkManager::ReAuthenticate ( )

Reauthenicate with the server.

void NetworkManager::ReConnect ( )

Reconnect to the server server.

void NetworkManager::RequestAllObjects ( ) [protected]

Number of command messages queued.

void NetworkManager::SendAllCommands ( bool  final = false)

Send the queued commands.

Parameters:
finalTrue if this is the final. And a forced sending should be done.
void NetworkManager::SendConsoleCommand ( const char *  cmd)

Send a console command.

Parameters:
cmdThe command to send.

Member Data Documentation

Entities queued for sending of DR.

Definition at line 67 of file networkmgr.h.

csHash<NPC*,PID> NetworkManager::cmd_dr_outbound [protected]

Definition at line 66 of file networkmgr.h.

bool NetworkManager::connected [protected]

Definition at line 62 of file networkmgr.h.

Definition at line 60 of file networkmgr.h.

csString NetworkManager::host [protected]

Definition at line 204 of file networkmgr.h.

Definition at line 59 of file networkmgr.h.

Definition at line 65 of file networkmgr.h.

csString NetworkManager::password [protected]

Definition at line 204 of file networkmgr.h.

Definition at line 205 of file networkmgr.h.

bool NetworkManager::ready [protected]

Definition at line 61 of file networkmgr.h.

Set to true if reconnect should be done.

Definition at line 510 of file networkmgr.h.

csString NetworkManager::user [protected]

Definition at line 204 of file networkmgr.h.


The documentation for this class was generated from the following file: