mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-09-12 22:45:02 -04:00
more conversion, 100% gurantee there will be errors here until i fix
This commit is contained in:
@@ -17,38 +17,7 @@
|
||||
#include "sharedNetworkMessages/ChatOnLeaveRoom.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/*
|
||||
void putClientsInRoom(const unsigned int roomId, const std::vector<NetworkId> & clients)
|
||||
{
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = clients.begin(); i != clients.end(); ++i)
|
||||
{
|
||||
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
client->enterRoom(roomId);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/*
|
||||
void removeClientsFromRoom(const unsigned int roomId, const std::vector<NetworkId> & clients)
|
||||
{
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
for(i = clients.begin(); i != clients.end(); ++i)
|
||||
{
|
||||
|
||||
Client* client = ConnectionServer::getClient((*i));
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
client->leaveRoom(roomId);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//-----------------------------------------------------------------------
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
ChatServerConnection::ChatServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
@@ -104,41 +73,16 @@ void ChatServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage m(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if (m.isType("GameClientMessage"))
|
||||
{
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
|
||||
if (message.getType() == constcrc("GameClientMessage")) {
|
||||
//we're receiving a message to forward to the client.
|
||||
//it is prefixed with NetworkId and reliable.
|
||||
const GameClientMessage msg(ri);
|
||||
Archive::ReadIterator mri(msg.getByteStream());
|
||||
GameNetworkMessage gnm(mri);
|
||||
mri = msg.getByteStream().begin();
|
||||
|
||||
// The connection server wants to trap room
|
||||
// enter/leave messages to cache clients
|
||||
// in particular rooms for autorecovery when
|
||||
// a chat server process is stopped then later
|
||||
// restarted
|
||||
//
|
||||
// ************ THIS CODE DOES NOT WORK ***********
|
||||
// The following code has been commented out since
|
||||
// everyone in the group is sent these messages but
|
||||
// the logic assumes that only the person entering
|
||||
// or leaving a chat room is sent the message.
|
||||
/*
|
||||
if(gnm.isType("ChatOnEnteredRoom"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnEnteredRoom chat(cri);
|
||||
putClientsInRoom(chat.getRoomId(), msg.getDistributionList());
|
||||
}
|
||||
else if(gnm.isType("ChatOnLeaveRoom"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnLeaveRoom chat(cri);
|
||||
removeClientsFromRoom(chat.getRoomId(), msg.getDistributionList());
|
||||
}
|
||||
*/
|
||||
|
||||
const uint32 messageType = gnm.getType();
|
||||
|
||||
const std::vector<NetworkId> & d = msg.getDistributionList();
|
||||
std::vector<NetworkId>::const_iterator i;
|
||||
@@ -167,46 +111,55 @@ void ChatServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
DEBUG_REPORT_LOG(!client, ("Error, could not map %s to a client\n", (*i).getValueString().c_str()));
|
||||
if (client)
|
||||
{
|
||||
if (!gnm.isType("ChatStatisticsCS"))
|
||||
if (messageType !== constcrc("ChatStatisticsCS")) {
|
||||
client->getClientConnection()->sendByteStream(msg.getByteStream(), msg.getReliable());
|
||||
|
||||
}
|
||||
|
||||
GameConnection *gc = client->getGameConnection();
|
||||
|
||||
if (gc)
|
||||
{
|
||||
if (gnm.isType("ChatOnGetFriendsList"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetFriendsList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetFriendsList msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnChangeIgnoreStatus"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeIgnoreStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeIgnoreStatus msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnChangeFriendStatus"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeFriendStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeFriendStatus msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatOnGetIgnoreList"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetIgnoreList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetIgnoreList msg to game server\n"));
|
||||
}
|
||||
else if (gnm.isType("ChatStatisticsCS"))
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics(cri);
|
||||
gc->send(chatStatistics, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatStatisticsCS msg to game server\n"));
|
||||
switch(messageType) {
|
||||
case constcrc("ChatOnGetFriendsList") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetFriendsList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetFriendsList msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnChangeIgnoreStatus") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeIgnoreStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeIgnoreStatus msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnChangeFriendStatus") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnChangeFriendStatus c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnChangeFriendStatus msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatOnGetIgnoreList") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
ChatOnGetIgnoreList c(cri);
|
||||
gc->send(c, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatOnGetIgnoreList msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatStatisticsCS") :
|
||||
{
|
||||
Archive::ReadIterator cri(msg.getByteStream());
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, int>, std::pair<int, int> > > chatStatistics(cri);
|
||||
gc->send(chatStatistics, true);
|
||||
//DEBUG_REPORT_LOG(true, ("Sending a ChatStatisticsCS msg to game server\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "sharedNetworkMessages/DisconnectPlayerMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Client::Client(ClientConnection * cconn, const NetworkId& oid) :
|
||||
@@ -157,7 +159,9 @@ void Client::leaveRoom(const unsigned int roomId)
|
||||
|
||||
void Client::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("GameConnectionClosed"))
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
if(messageType == constcrc("GameConnectionClosed"))
|
||||
{
|
||||
// Game server has crashed. With luck, we'll get transferred to a new server shortly
|
||||
// So, clear our connection and put us on a queue. If we don't get transferred in a
|
||||
@@ -166,12 +170,12 @@ void Client::receiveMessage(const MessageDispatch::Emitter & source, const Messa
|
||||
m_gameConnection = 0;
|
||||
ConnectionServer::addRecoveringClient(getNetworkId());
|
||||
}
|
||||
else if(message.isType("ChatServerConnectionOpened"))
|
||||
else if(messageType == constcrc("ChatServerConnectionOpened"))
|
||||
{
|
||||
const ChatServerConnection & chatConnection = static_cast<const ChatServerConnection &>(source);
|
||||
setChatConnection(const_cast<ChatServerConnection*>(&chatConnection));
|
||||
}
|
||||
else if(message.isType("CustomerServiceConnectionOpened"))
|
||||
else if(messageType == constcrc("CustomerServiceConnectionOpened"))
|
||||
{
|
||||
const CustomerServiceConnection & customerServiceConnection = static_cast<const CustomerServiceConnection &>(source);
|
||||
setCustomerServiceConnection(const_cast<CustomerServiceConnection*>(&customerServiceConnection));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user