Preparing unsubscribing/resubscribing of the game list updates to (hopefully) limit server bandwidth usage.
This commit is contained in:
@@ -343,6 +343,43 @@ Server Reply: Unknown Player Id
|
|||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
|
Client Request: Unsubscribe Game List Messages
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Message Type = 35 | Message Length = 8 |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
(This request will not be confirmed by the server. It is used, optionally,
|
||||||
|
to reduce server traffic. The server might ignore it.)
|
||||||
|
|
||||||
|
|
||||||
|
Client Request: Resubscribe Game List Messages
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Message Type = 36 | Message Length = 8 |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
(If previously unsubscribed, this will result in the whole game list
|
||||||
|
being sent by the server.)
|
||||||
|
|
||||||
|
|
||||||
|
Server Reply: Game List Messages Unsubscribed
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Message Type = 36 | Message Length = 8 |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
Client Request: Create Game
|
Client Request: Create Game
|
||||||
|
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ using namespace std;
|
|||||||
#define NET_TYPE_RETRIEVE_PLAYER_INFO 0x0020
|
#define NET_TYPE_RETRIEVE_PLAYER_INFO 0x0020
|
||||||
#define NET_TYPE_PLAYER_INFO 0x0021
|
#define NET_TYPE_PLAYER_INFO 0x0021
|
||||||
#define NET_TYPE_UNKNOWN_PLAYER_ID 0x0022
|
#define NET_TYPE_UNKNOWN_PLAYER_ID 0x0022
|
||||||
|
#define NET_TYPE_UNSUBSCRIBE_GAME_LIST 0x0023
|
||||||
|
#define NET_TYPE_RESUBSCRIBE_GAME_LIST 0x0024
|
||||||
#define NET_TYPE_CREATE_GAME 0x0030
|
#define NET_TYPE_CREATE_GAME 0x0030
|
||||||
#define NET_TYPE_JOIN_GAME 0x0031
|
#define NET_TYPE_JOIN_GAME 0x0031
|
||||||
#define NET_TYPE_JOIN_GAME_ACK 0x0032
|
#define NET_TYPE_JOIN_GAME_ACK 0x0032
|
||||||
@@ -279,6 +281,18 @@ struct GCC_PACKED NetPacketUnknownPlayerIdData
|
|||||||
u_int32_t playerId;
|
u_int32_t playerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketUnsubscribeGameListData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketResubscribeGameListData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
struct GCC_PACKED NetPacketCreateGameData
|
struct GCC_PACKED NetPacketCreateGameData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
@@ -712,6 +726,12 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
case NET_TYPE_UNKNOWN_PLAYER_ID:
|
case NET_TYPE_UNKNOWN_PLAYER_ID:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketUnknownPlayerId);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketUnknownPlayerId);
|
||||||
break;
|
break;
|
||||||
|
case NET_TYPE_UNSUBSCRIBE_GAME_LIST:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketUnsubscribeGameList);
|
||||||
|
break;
|
||||||
|
case NET_TYPE_RESUBSCRIBE_GAME_LIST:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketResubscribeGameList);
|
||||||
|
break;
|
||||||
case NET_TYPE_CREATE_GAME:
|
case NET_TYPE_CREATE_GAME:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketCreateGame);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketCreateGame);
|
||||||
break;
|
break;
|
||||||
@@ -979,6 +999,18 @@ NetPacket::ToNetPacketUnknownPlayerId() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetPacketUnsubscribeGameList *
|
||||||
|
NetPacket::ToNetPacketUnsubscribeGameList() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketResubscribeGameList *
|
||||||
|
NetPacket::ToNetPacketResubscribeGameList() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const NetPacketCreateGame *
|
const NetPacketCreateGame *
|
||||||
NetPacket::ToNetPacketCreateGame() const
|
NetPacket::ToNetPacketCreateGame() const
|
||||||
{
|
{
|
||||||
@@ -2349,6 +2381,81 @@ NetPacketUnknownPlayerId::InternalCheck(const NetPacketHeader*) const
|
|||||||
{
|
{
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketUnsubscribeGameList::NetPacketUnsubscribeGameList()
|
||||||
|
: NetPacket(NET_TYPE_UNSUBSCRIBE_GAME_LIST, sizeof(NetPacketUnsubscribeGameListData), sizeof(NetPacketUnsubscribeGameListData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketUnsubscribeGameList::~NetPacketUnsubscribeGameList()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketUnsubscribeGameList::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketUnsubscribeGameList);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketUnsubscribeGameList *
|
||||||
|
NetPacketUnsubscribeGameList::ToNetPacketUnsubscribeGameList() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketUnsubscribeGameList::InternalCheck(const NetPacketHeader*) const
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketResubscribeGameList::NetPacketResubscribeGameList()
|
||||||
|
: NetPacket(NET_TYPE_RESUBSCRIBE_GAME_LIST, sizeof(NetPacketResubscribeGameListData), sizeof(NetPacketResubscribeGameListData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketResubscribeGameList::~NetPacketResubscribeGameList()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketResubscribeGameList::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketResubscribeGameList);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketResubscribeGameList *
|
||||||
|
NetPacketResubscribeGameList::ToNetPacketResubscribeGameList() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketResubscribeGameList::InternalCheck(const NetPacketHeader*) const
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NetPacketCreateGame::NetPacketCreateGame()
|
NetPacketCreateGame::NetPacketCreateGame()
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class NetPacketGameListAdminChanged;
|
|||||||
class NetPacketRetrievePlayerInfo;
|
class NetPacketRetrievePlayerInfo;
|
||||||
class NetPacketPlayerInfo;
|
class NetPacketPlayerInfo;
|
||||||
class NetPacketUnknownPlayerId;
|
class NetPacketUnknownPlayerId;
|
||||||
|
class NetPacketUnsubscribeGameList;
|
||||||
|
class NetPacketResubscribeGameList;
|
||||||
class NetPacketCreateGame;
|
class NetPacketCreateGame;
|
||||||
class NetPacketJoinGame;
|
class NetPacketJoinGame;
|
||||||
class NetPacketJoinGameAck;
|
class NetPacketJoinGameAck;
|
||||||
@@ -125,6 +127,8 @@ public:
|
|||||||
virtual const NetPacketRetrievePlayerInfo *ToNetPacketRetrievePlayerInfo() const;
|
virtual const NetPacketRetrievePlayerInfo *ToNetPacketRetrievePlayerInfo() const;
|
||||||
virtual const NetPacketPlayerInfo *ToNetPacketPlayerInfo() const;
|
virtual const NetPacketPlayerInfo *ToNetPacketPlayerInfo() const;
|
||||||
virtual const NetPacketUnknownPlayerId *ToNetPacketUnknownPlayerId() const;
|
virtual const NetPacketUnknownPlayerId *ToNetPacketUnknownPlayerId() const;
|
||||||
|
virtual const NetPacketUnsubscribeGameList *ToNetPacketUnsubscribeGameList() const;
|
||||||
|
virtual const NetPacketResubscribeGameList *ToNetPacketResubscribeGameList() const;
|
||||||
virtual const NetPacketCreateGame *ToNetPacketCreateGame() const;
|
virtual const NetPacketCreateGame *ToNetPacketCreateGame() const;
|
||||||
virtual const NetPacketJoinGame *ToNetPacketJoinGame() const;
|
virtual const NetPacketJoinGame *ToNetPacketJoinGame() const;
|
||||||
virtual const NetPacketJoinGameAck *ToNetPacketJoinGameAck() const;
|
virtual const NetPacketJoinGameAck *ToNetPacketJoinGameAck() const;
|
||||||
@@ -541,6 +545,38 @@ protected:
|
|||||||
virtual void InternalCheck(const NetPacketHeader* data) const;
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NetPacketUnsubscribeGameList : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
NetPacketUnsubscribeGameList();
|
||||||
|
virtual ~NetPacketUnsubscribeGameList();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
virtual const NetPacketUnsubscribeGameList *ToNetPacketUnsubscribeGameList() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NetPacketResubscribeGameList : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
NetPacketResubscribeGameList();
|
||||||
|
virtual ~NetPacketResubscribeGameList();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
virtual const NetPacketResubscribeGameList *ToNetPacketResubscribeGameList() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
class NetPacketCreateGame : public NetPacket
|
class NetPacketCreateGame : public NetPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user