Changeset 9b5d30b in network-game for common


Ignore:
Timestamp:
Jul 14, 2013, 9:22:38 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
10f6fc2
Parents:
5a64bea
Message:

Moved server message sending/receiving into MessageProcessor

Location:
common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • common/Message.cpp

    r5a64bea r9b5d30b  
    1515using namespace std;
    1616
     17/*
    1718int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
    1819{
     
    3334   return ret;
    3435}
     36*/
  • common/Message.h

    r5a64bea r9b5d30b  
    2626} NETWORK_MSG;
    2727
    28 int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest);
     28//int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest);
    2929
    30 int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source);
     30//int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source);
    3131
    3232#endif
  • common/MessageProcessor.cpp

    r5a64bea r9b5d30b  
    1111
    1212int MessageProcessor::sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest) {
     13   msg->id = ++lastUsedId;
    1314   MessageContainer message(*msg, *dest);
    14    message.id = ++lastUsedId;
    15    sentMessages[message.id] = message;
     15   sentMessages[msg->id] = message;
    1616
    1717   int ret =  sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
  • common/MessageProcessor.h

    r5a64bea r9b5d30b  
    5959
    6060      MessageContainer(const MessageContainer& mc) {
    61          this->id = mc.id;
     61         this->msg = mc.msg;
    6262         this->clientAddr = mc.clientAddr;
    63          this->msg = mc.msg;
    64          this->ackReceived = mc.ackReceived;
    6563      }
    6664
     
    7371      }
    7472
    75       int id;
     73      NETWORK_MSG msg;
    7674      struct sockaddr_in clientAddr;
    77       NETWORK_MSG msg;
    78       bool ackReceived;
    7975   };
    8076
Note: See TracChangeset for help on using the changeset viewer.