source: network-game/common/MessageProcessor.h@ 9ee50ce

Last change on this file since 9ee50ce 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
Line 
1#ifndef _MESSAGE_PROCESSOR_H
2#define _MESSAGE_PROCESSOR_H
3
4#include <map>
5
6#include "MessageContainer.h"
7#include "Player.h"
8
9using namespace std;
10
11class MessageProcessor {
12private:
13 int sock;
14 ofstream* outputLog;
15 int lastUsedId;
16
17 // map from message ids to maps from player addresses to message info
18 map<unsigned int, map<unsigned long, MessageContainer> > sentMessages;
19
20 // map from player address to map from message id to time accked
21 map<unsigned long, map<unsigned int, unsigned long long> > ackedMessages;
22
23 //unsigned long pid;
24
25public:
26 MessageProcessor();
27 MessageProcessor(int sock, ofstream* outputLog = NULL);
28 ~MessageProcessor();
29
30 int sendMessage(NETWORK_MSG *msg, struct sockaddr_in *dest);
31 int receiveMessage(NETWORK_MSG *msg, struct sockaddr_in *source);
32 void broadcastMessage(NETWORK_MSG &msg, map<unsigned int, Player*>& players);
33 void resendUnackedMessages();
34 void cleanAckedMessages();
35
36 map<unsigned int, map<unsigned long, MessageContainer> >& getSentMessages();
37 map<unsigned long, map<unsigned int, unsigned long long> >& getAckedMessages();
38};
39
40#endif
Note: See TracBrowser for help on using the repository browser.