Changeset 68d94de in network-game for common


Ignore:
Timestamp:
Dec 24, 2013, 3:02:22 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
8554263
Parents:
e1af80c
Message:

MessageProcessor now takes a socket and optional output log file as constructor arguments instead of accepting them as parameters in each method

Location:
common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/MessageProcessor.cpp

    re1af80c r68d94de  
    1313
    1414MessageProcessor::MessageProcessor() {
     15   this->sock = 0;
     16   this->outputLog = NULL;
     17   lastUsedId = 0;
     18}
     19
     20MessageProcessor::MessageProcessor(int sock, ofstream* outputLog) {
     21   this->sock = sock;
     22   this->outputLog = outputLog;
    1523   lastUsedId = 0;
    1624}
     
    1927}
    2028
    21 int MessageProcessor::sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest, ofstream* outputLog) {
     29int MessageProcessor::sendMessage(NETWORK_MSG *msg, struct sockaddr_in *dest) {
    2230   cout << "Sending message of type " << msg->type << endl;
    2331
     
    3543}
    3644
    37 int MessageProcessor::receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source, ofstream* outputLog) {
     45int MessageProcessor::receiveMessage(NETWORK_MSG *msg, struct sockaddr_in *source) {
    3846   socklen_t socklen = sizeof(struct sockaddr_in);
    3947
     
    8492}
    8593
    86 void MessageProcessor::resendUnackedMessages(int sock, ofstream* outputLog) {
     94void MessageProcessor::resendUnackedMessages() {
    8795   map<unsigned int, map<unsigned long, MessageContainer> >::iterator it;
    8896   map<unsigned long, MessageContainer>::iterator it2;
     
    99107}
    100108
    101 void MessageProcessor::cleanAckedMessages(ofstream* outputLog) {
     109void MessageProcessor::cleanAckedMessages() {
    102110   map<unsigned int, map<unsigned long, MessageContainer> >::iterator it = sentMessages.begin();
    103111   map<unsigned long, MessageContainer>::iterator it2;
  • common/MessageProcessor.h

    re1af80c r68d94de  
    1010class MessageProcessor {
    1111private:
     12   int sock;
     13   ofstream* outputLog;
    1214   int lastUsedId;
    1315
     
    1820   map<unsigned long, map<unsigned int, unsigned long long> > ackedMessages;
    1921
    20    unsigned long pid;
     22   //unsigned long pid;
    2123
    2224public:
    2325   MessageProcessor();
     26   MessageProcessor(int sock, ofstream* outputLog = NULL);
    2427   ~MessageProcessor();
    2528
    26    int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest, ofstream* outputLog = NULL);
    27    int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest, ofstream* outputLog = NULL);
    28    void resendUnackedMessages(int sock, ofstream* outputLog = NULL);
    29    void cleanAckedMessages(ofstream* outputLog = NULL);
     29   int sendMessage(NETWORK_MSG *msg, struct sockaddr_in *dest);
     30   int receiveMessage(NETWORK_MSG *msg, struct sockaddr_in *source);
     31   void resendUnackedMessages();
     32   void cleanAckedMessages();
    3033
    3134   map<unsigned int, map<unsigned long, MessageContainer> >& getSentMessages();
Note: See TracChangeset for help on using the changeset viewer.