Changeset 787806f in network-game


Ignore:
Timestamp:
Jul 2, 2013, 10:24:22 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
1a3c42d
Parents:
f3cf1a5
Message:

Added an ACK message type and a skeleton MessageProcessor class

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/Message.cpp

    rf3cf1a5 r787806f  
    2424}
    2525
    26 int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
     26int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source)
    2727{
    2828   socklen_t socklen = sizeof(struct sockaddr_in);
    2929
    3030   // assume we don't care about the value of socklen
    31    int ret =  recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, &socklen);
     31   int ret =  recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)source, &socklen);
    3232
    3333   return ret;
  • common/Message.h

    rf3cf1a5 r787806f  
    22#define _MESSAGE_H
    33
    4 #define MSG_TYPE_REGISTER          1
    5 #define MSG_TYPE_LOGIN             2
    6 #define MSG_TYPE_LOGOUT            3
    7 #define MSG_TYPE_CHAT              4
    8 #define MSG_TYPE_PLAYER            5  // server sends this to update player positions
    9 #define MSG_TYPE_PLAYER_MOVE       6  // client sends this when a player wants to move
    10 #define MSG_TYPE_OBJECT            7
    11 #define MSG_TYPE_REMOVE_OBJECT     8
    12 #define MSG_TYPE_PICKUP_FLAG       9
    13 #define MSG_TYPE_DROP_FLAG         10
    14 #define MSG_TYPE_SCORE             11
    15 #define MSG_TYPE_START_ATTACK      12
    16 #define MSG_TYPE_ATTACK            13
    17 #define MSG_TYPE_PROJECTILE        14
    18 #define MSG_TYPE_REMOVE_PROJECTILE 15
     4#define MSG_TYPE_ACK               1
     5#define MSG_TYPE_REGISTER          2
     6#define MSG_TYPE_LOGIN             3
     7#define MSG_TYPE_LOGOUT            4
     8#define MSG_TYPE_CHAT              5
     9#define MSG_TYPE_PLAYER            6  // server sends this to update player positions
     10#define MSG_TYPE_PLAYER_MOVE       7  // client sends this when a player wants to move
     11#define MSG_TYPE_OBJECT            8
     12#define MSG_TYPE_REMOVE_OBJECT     9
     13#define MSG_TYPE_PICKUP_FLAG       10
     14#define MSG_TYPE_DROP_FLAG         11
     15#define MSG_TYPE_SCORE             12
     16#define MSG_TYPE_START_ATTACK      13
     17#define MSG_TYPE_ATTACK            14
     18#define MSG_TYPE_PROJECTILE        15
     19#define MSG_TYPE_REMOVE_PROJECTILE 16
    1920
    2021typedef struct
     
    2627int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest);
    2728
    28 int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest);
     29int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source);
    2930
    3031#endif
  • server/makefile

    rf3cf1a5 r787806f  
    33FLAGS = $(LIB_FLAGS)
    44COMMON_PATH = ../common
    5 DEPENDENCIES = Common.o Message.o Player.o WorldMap.o DataAccess.o Projectile.o
     5DEPENDENCIES = Common.o Message.o MessageProcessor.o Player.o WorldMap.o DataAccess.o Projectile.o
    66
    77server : server.cpp $(DEPENDENCIES)
     
    1212
    1313Message.o : $(COMMON_PATH)/Message.cpp
     14        $(CC) -c -o $@ $?
     15
     16MessageProcessor.o : $(COMMON_PATH)/MessageProcessor.cpp
    1417        $(CC) -c -o $@ $?
    1518
Note: See TracChangeset for help on using the changeset viewer.