TrinityCore
ConnectionService.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ConnectionService.h"
19#include "Duration.h"
20#include "Util.h"
22
24{
25}
26
27uint32 Battlenet::Services::Connection::HandleConnect(connection::v1::ConnectRequest const* request, connection::v1::ConnectResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/)
28{
29 if (request->has_client_id())
30 response->mutable_client_id()->CopyFrom(request->client_id());
31
32 std::chrono::system_clock::duration now = std::chrono::system_clock::now().time_since_epoch();
33
34 response->mutable_server_id()->set_label(GetPID());
35 response->mutable_server_id()->set_epoch(std::chrono::duration_cast<Seconds>(now).count());
36 response->set_server_time(std::chrono::duration_cast<Milliseconds>(now).count());
37
38 response->set_use_bindless_rpc(request->use_bindless_rpc());
39 return ERROR_OK;
40}
41
43{
44 return ERROR_OK;
45}
46
48{
49 connection::v1::DisconnectNotification disconnectNotification;
50 disconnectNotification.set_error_code(request->error_code());
51 ForceDisconnect(&disconnectNotification);
52
53 _session->DelayedCloseSocket();
54 return ERROR_OK;
55}
uint32_t uint32
Definition: Define.h:142
uint32 GetPID()
Definition: Util.cpp:338
uint32 HandleKeepAlive(NoData const *request) override
uint32 HandleRequestDisconnect(connection::v1::DisconnectRequest const *request) override
uint32 HandleConnect(connection::v1::ConnectRequest const *request, connection::v1::ConnectResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
void set_error_code(::google::protobuf::uint32 value)