source: network-game/common/MessageProcessor.h@ 0678d60

Last change on this file since 0678d60 was d05c484, checked in by dportnoy <dmp1488@…>, 11 years ago

Some game-specific functions moved from server.cpp to the Game class and a function moved to the MessageProcessor class

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[1a3c42d]1#ifndef _MESSAGE_PROCESSOR_H
2#define _MESSAGE_PROCESSOR_H
3
[5a64bea]4#include <map>
5
[46d6469]6#include "MessageContainer.h"
[d05c484]7#include "Player.h"
[5a64bea]8
[46d6469]9using namespace std;
[5a64bea]10
[46d6469]11class MessageProcessor {
12private:
[68d94de]13 int sock;
14 ofstream* outputLog;
[46d6469]15 int lastUsedId;
[1a3c42d]16
[46d6469]17 // map from message ids to maps from player addresses to message info
[b35b2b2]18 map<unsigned int, map<unsigned long, MessageContainer> > sentMessages;
[1a3c42d]19
[f9cb9fb]20 // map from player address to map from message id to time accked
21 map<unsigned long, map<unsigned int, unsigned long long> > ackedMessages;
[46d6469]22
[68d94de]23 //unsigned long pid;
[5a64bea]24
[1a3c42d]25public:
[5a64bea]26 MessageProcessor();
[68d94de]27 MessageProcessor(int sock, ofstream* outputLog = NULL);
[5a64bea]28 ~MessageProcessor();
29
[68d94de]30 int sendMessage(NETWORK_MSG *msg, struct sockaddr_in *dest);
31 int receiveMessage(NETWORK_MSG *msg, struct sockaddr_in *source);
[d05c484]32 void broadcastMessage(NETWORK_MSG &msg, map<unsigned int, Player*>& players);
[68d94de]33 void resendUnackedMessages();
34 void cleanAckedMessages();
[b35b2b2]35
36 map<unsigned int, map<unsigned long, MessageContainer> >& getSentMessages();
[f9cb9fb]37 map<unsigned long, map<unsigned int, unsigned long long> >& getAckedMessages();
[1a3c42d]38};
39
40#endif
Note: See TracBrowser for help on using the repository browser.