Authserver/BattleNet: Added some initial work in the Friends (3) and Presence (4) Battle.net channels

This commit is contained in:
Subv
2014-10-05 17:21:17 -05:00
parent 238b194709
commit ee274a792c
5 changed files with 369 additions and 2 deletions

View File

@@ -58,6 +58,14 @@ namespace Battlenet
_creators[PacketHeader(WoWRealm::CMSG_LIST_SUBSCRIBE_REQUEST, WOWREALM)] = &New<WoWRealm::ListSubscribeRequest>;
_creators[PacketHeader(WoWRealm::CMSG_JOIN_REQUEST_V2, WOWREALM)] = &New<WoWRealm::JoinRequestV2>;
_creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS)] = &New<Friends::SocialnetworkCheckConnected>;
// _creators[PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS)] = &New<Friends::SocialnetworkConnect>;
// _creators[PacketHeader(Friends::CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS)] = &New<Friends::GetFriendsOfFriend>;
_creators[PacketHeader(Friends::CMSG_REALID_FRIEND_INVITE, FRIENDS)] = &New<Friends::RealIdFriendInvite>;
// _creators[PacketHeader(Presence::CMSG_UPDATE_REQUEST, PRESENCE)] = &New<Presence::UpdateRequest>;
// _creators[PacketHeader(Presence::CMSG_STATISTIC_SUBSCRIBE, PRESENCE)] = &New<Presence::StatisticSubscribe>;
}
template<class PacketType>

View File

@@ -0,0 +1,180 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BattlenetSession.h"
#include "FriendsPackets.h"
void Battlenet::Friends::SocialnetworkCheckConnected::Read()
{
SocialNetworkId = _stream.Read<uint32>(32);
}
std::string Battlenet::Friends::SocialnetworkCheckConnected::ToString() const
{
return "Battlenet::Friends::SocialnetworkCheckConnected SocialNetworkId " + std::to_string(SocialNetworkId);
}
void Battlenet::Friends::SocialnetworkCheckConnected::CallHandler(Session* session) const
{
SocialNetworkCheckConnectedResult* result = new SocialNetworkCheckConnectedResult(SocialNetworkId);
session->AsyncWrite(result);
}
void Battlenet::Friends::SocialnetworkConnect::Read()
{
int32 unk1 = _stream.Read<int32>(32);
uint32 size1 = _stream.Read<uint32>(9);
auto data1 = _stream.ReadBytes(size1);
uint32 size2 = _stream.Read<uint32>(7);
auto data2 = _stream.ReadBytes(size2);
}
std::string Battlenet::Friends::SocialnetworkConnect::ToString() const
{
return "Battlenet::Friends::SocialnetworkConnect";
}
void Battlenet::Friends::SocialnetworkConnect::CallHandler(Session* session) const
{
}
std::string Battlenet::Friends::SocialNetworkConnectResult::ToString() const
{
return "Battlenet::Friends::SocialNetworkConnectResult";
}
void Battlenet::Friends::SocialNetworkConnectResult::Write()
{
}
std::string Battlenet::Friends::SocialNetworkCheckConnectedResult::ToString() const
{
return "Battlenet::Friends::SocialNetworkCheckConnectedResult";
}
void Battlenet::Friends::SocialNetworkCheckConnectedResult::Write()
{
_stream.Write(0, 23); // Ignored
volatile uint16 res = 0;
_stream.Write(res, 16); // Unknown
_stream.Write(SocialNetworkId, 32);
}
void Battlenet::Friends::GetFriendsOfFriend::Read()
{
uint8 unk = _stream.Read<uint8>(2);
uint32 unk1 = _stream.Read<uint32>(32);
}
std::string Battlenet::Friends::GetFriendsOfFriend::ToString() const
{
return "Battlenet::Friends::GetFriendsOfFriend";
}
void Battlenet::Friends::GetFriendsOfFriend::CallHandler(Session* session) const
{
}
void Battlenet::Friends::RealIdFriendInvite::Read()
{
_stream.Read<uint32>(32);
uint8 type = _stream.Read<uint8>(3);
switch (type)
{
case 0:
{
_stream.Read<uint32>(32); // Presence Id?
break;
}
case 1: // GameAccount?
{
_stream.Read<uint8>(8);
_stream.Read<uint32>(32);
_stream.Read<uint32>(32);
uint8 size = _stream.Read<uint8>(7); // Only if *(a1 + 16) <= 0x64
_stream.ReadBytes(size);
break;
}
case 2:
Email = _stream.ReadString(9, 3);
break;
case 3:
{
_stream.Read<uint32>(32);
break;
}
case 4:
{
_stream.Read<uint64>(64);
_stream.Read<uint32>(32);
break;
}
}
_stream.Read<uint8>(1);
if (_stream.Read<uint8>(1))
Message = _stream.ReadString(9);
_stream.Read<uint32>(32);
}
std::string Battlenet::Friends::RealIdFriendInvite::ToString() const
{
return "Battlenet::Friends::RealIdFriendInvite Mail: " + Email + " Message: " + Message;
}
void Battlenet::Friends::RealIdFriendInvite::CallHandler(Session* session) const
{
FriendInviteResult* result = new FriendInviteResult();
session->AsyncWrite(result);
}
std::string Battlenet::Friends::FriendInviteResult::ToString() const
{
return "Battlenet::Friends::RealIdFriendInviteResult";
}
void Battlenet::Friends::FriendInviteResult::Write()
{
bool hasNames = false;
_stream.Write(hasNames, 1);
if (hasNames)
{
_stream.WriteString("Testing1", 8);
_stream.WriteString("Testing2", 8);
}
_stream.Write(5, 32);
_stream.Write(0, 0xC); // Ignored
_stream.Write(1, 16);
bool moreInfo = true;
_stream.Write(moreInfo, 1);
if (moreInfo)
{
_stream.Write(0, 8);
_stream.Write(4, 32);
_stream.Write(3, 32);
_stream.WriteString("Testing3", 7, 2);
}
}

View File

@@ -37,7 +37,7 @@ namespace Battlenet
CMSG_GET_SOCIAL_NETWORK_FRIENDS = 0x0D, // Not implemented
CMSG_SOCIAL_NETWORK_CONNECT = 0x0F, // Not implemented
CMSG_SOCIAL_NETWORK_DISCONNECT = 0x11, // Not implemented
CMSG_SOCIAL_NETWORK_CHECK_CONNECTED = 0x13, // Not implemented
CMSG_SOCIAL_NETWORK_CHECK_CONNECTED = 0x13,
CMSG_REALID_FRIEND_INVITE = 0x16, // Not implemented
SMSG_FRIEND_INVITE_NOTIFY = 0x01, // Not implemented
@@ -49,10 +49,113 @@ namespace Battlenet
SMSG_SOCIAL_NETWORK_FRIENDS = 0x0E, // Not implemented
SMSG_SOCIAL_NETWORK_CONNECT_RESULT = 0x10, // Not implemented
SMSG_SOCIAL_NETWORK_DISCONNECT_RESULT = 0x12, // Not implemented
SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT = 0x14, // Not implemented
SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT = 0x14,
SMSG_MAX_FRIENDS_NOTIFY = 0x15, // Not implemented
SMSG_FRIENDS_LIST_NOTIFY_3 = 0x18 // Not implemented
};
class SocialnetworkConnect final : public ClientPacket
{
public:
SocialnetworkConnect(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS) && "Invalid packet header for SocialnetworkConnect");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
};
class SocialNetworkConnectResult final : public ServerPacket
{
public:
SocialNetworkConnectResult() : ServerPacket(PacketHeader(SMSG_SOCIAL_NETWORK_CONNECT_RESULT, FRIENDS))
{
}
void Write() override;
std::string ToString() const override;
};
class SocialnetworkCheckConnected final : public ClientPacket
{
public:
SocialnetworkCheckConnected(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS) && "Invalid packet header for SocialNetworkCheckConnected");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
uint32 SocialNetworkId;
};
class SocialNetworkCheckConnectedResult final : public ServerPacket
{
public:
SocialNetworkCheckConnectedResult(uint32 socialNetworkId) : ServerPacket(PacketHeader(SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT, FRIENDS)), SocialNetworkId(socialNetworkId)
{
}
void Write() override;
std::string ToString() const override;
uint32 SocialNetworkId;
};
class GetFriendsOfFriend final : public ClientPacket
{
public:
GetFriendsOfFriend(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS) && "Invalid packet header for GetFriendsOfFriend");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
};
class FriendsOfFriend final : public ServerPacket
{
public:
FriendsOfFriend() : ServerPacket(PacketHeader(SMSG_FRIENDS_OF_FRIEND, FRIENDS))
{
}
void Write() override;
std::string ToString() const override;
};
class RealIdFriendInvite final : public ClientPacket
{
public:
RealIdFriendInvite(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_REALID_FRIEND_INVITE, FRIENDS) && "Invalid packet header for RealIdFriendInvite");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
std::string Email;
std::string Message;
};
class FriendInviteResult final : public ServerPacket
{
public:
FriendInviteResult() : ServerPacket(PacketHeader(SMSG_FRIEND_INVITE_RESULT, FRIENDS))
{
}
void Write() override;
std::string ToString() const override;
};
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BattlenetSession.h"
#include "PresencePackets.h"
f
void Battlenet::Presence::UpdateRequest::Read()
{
}
std::string Battlenet::Presence::UpdateRequest::ToString() const
{
return "Battlenet::Presence::UpdateRequest";
}
void Battlenet::Presence::UpdateRequest::CallHandler(Session* session) const
{
}
void Battlenet::Presence::StatisticSubscribe::Read()
{
}
std::string Battlenet::Presence::StatisticSubscribe::ToString() const
{
return "Battlenet::Presence::StatisticSubscribe";
}
void Battlenet::Presence::StatisticSubscribe::CallHandler(Session* session) const
{
}

View File

@@ -33,6 +33,32 @@ namespace Battlenet
SMSG_FIELD_SPEC_ANNOUNCE = 0x1, // Not implemented
SMSG_STATISTICS_UPDATE = 0x3 // Not implemented
};
class UpdateRequest final : public ClientPacket
{
public:
UpdateRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_UPDATE_REQUEST, PRESENCE) && "Invalid packet header for UpdateRequest");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
};
class StatisticSubscribe final : public ClientPacket
{
public:
StatisticSubscribe(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream)
{
ASSERT(header == PacketHeader(CMSG_STATISTIC_SUBSCRIBE, PRESENCE) && "Invalid packet header for StatisticSubscribe");
}
void Read() override;
std::string ToString() const override;
void CallHandler(Session* session) const override;
};
}
}