1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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 "WorldSession.h"
#include "BattlenetPackets.h"
#include "WorldserverServiceDispatcher.h"
#include "ObjectDefines.h"
void WorldSession::HandleBattlenetRequest(WorldPackets::Battlenet::Request& request)
{
sServiceDispatcher.Dispatch(this, request.Method.GetServiceHash(), request.Method.Token, request.Method.GetMethodId(), std::move(request.Data));
}
void WorldSession::HandleBattlenetRequestRealmListTicket(WorldPackets::Battlenet::RequestRealmListTicket& requestRealmListTicket)
{
SetRealmListSecret(requestRealmListTicket.Secret);
WorldPackets::Battlenet::RealmListTicket realmListTicket;
realmListTicket.Token = requestRealmListTicket.Token;
realmListTicket.Allow = true;
realmListTicket.Ticket << "WorldserverRealmListTicket";
SendPacket(realmListTicket.Write());
}
void WorldSession::SendBattlenetResponse(uint32 serviceHash, uint32 methodId, uint32 token, pb::Message const* response)
{
WorldPackets::Battlenet::Response bnetResponse;
bnetResponse.BnetStatus = ERROR_OK;
bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
bnetResponse.Method.ObjectId = 1;
bnetResponse.Method.Token = token;
if (response->ByteSize())
{
bnetResponse.Data.resize(response->ByteSize());
response->SerializePartialToArray(bnetResponse.Data.contents(), response->ByteSize());
}
SendPacket(bnetResponse.Write());
}
void WorldSession::SendBattlenetResponse(uint32 serviceHash, uint32 methodId, uint32 token, uint32 status)
{
WorldPackets::Battlenet::Response bnetResponse;
bnetResponse.BnetStatus = BattlenetRpcErrorCode(status);
bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
bnetResponse.Method.ObjectId = 1;
bnetResponse.Method.Token = token;
SendPacket(bnetResponse.Write());
}
void WorldSession::SendBattlenetRequest(uint32 serviceHash, uint32 methodId, pb::Message const* request, std::function<void(MessageBuffer)> callback)
{
_battlenetResponseCallbacks[_battlenetRequestToken] = std::move(callback);
SendBattlenetRequest(serviceHash, methodId, request);
}
void WorldSession::SendBattlenetRequest(uint32 serviceHash, uint32 methodId, pb::Message const* request)
{
WorldPackets::Battlenet::Notification notification;
notification.Method.Type = MAKE_PAIR64(methodId, serviceHash);
notification.Method.ObjectId = 1;
notification.Method.Token = _battlenetRequestToken++;
if (request->ByteSize())
{
notification.Data.resize(request->ByteSize());
request->SerializePartialToArray(notification.Data.contents(), request->ByteSize());
}
SendPacket(notification.Write());
}
|