forked from vmangos/core
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
352 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (C) 2008-2019 TrinityCore <https://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 "ConnectionService.h" | ||
#include "Duration.h" | ||
#include "Log.h" | ||
#include "AuthSocket.h" | ||
#include "Util.h" | ||
#include "BattlenetRpcErrorCodes.h" | ||
|
||
Battlenet::Services::Connection::Connection(AuthSocket* session) : ConnectionService(session) | ||
{ | ||
} | ||
|
||
uint32 Battlenet::Services::Connection::HandleConnect(connection::v1::ConnectRequest const* request, connection::v1::ConnectResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/) | ||
{ | ||
if (request->has_client_id()) | ||
response->mutable_client_id()->CopyFrom(request->client_id()); | ||
|
||
std::chrono::system_clock::duration now = std::chrono::system_clock::now().time_since_epoch(); | ||
|
||
response->mutable_server_id()->set_label(GetPID()); | ||
response->mutable_server_id()->set_epoch(std::chrono::duration_cast<Seconds>(now).count()); | ||
response->set_server_time(std::chrono::duration_cast<Milliseconds>(now).count()); | ||
|
||
response->set_use_bindless_rpc(request->use_bindless_rpc()); | ||
return ERROR_OK; | ||
} | ||
|
||
uint32 Battlenet::Services::Connection::HandleKeepAlive(NoData const* /*request*/) | ||
{ | ||
return ERROR_OK; | ||
} | ||
|
||
uint32 Battlenet::Services::Connection::HandleRequestDisconnect(connection::v1::DisconnectRequest const* request) | ||
{ | ||
connection::v1::DisconnectNotification disconnectNotification; | ||
disconnectNotification.set_error_code(request->error_code()); | ||
ForceDisconnect(&disconnectNotification); | ||
|
||
_session->close_connection(); | ||
return ERROR_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2008-2019 TrinityCore <https://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/>. | ||
*/ | ||
|
||
#ifndef ConnectionService_h__ | ||
#define ConnectionService_h__ | ||
|
||
#include "Common.h" | ||
#include "Service.h" | ||
#include "connection_service.pb.h" | ||
|
||
class AuthSocket; | ||
|
||
namespace Battlenet | ||
{ | ||
namespace Services | ||
{ | ||
class Connection : public Service<connection::v1::ConnectionService> | ||
{ | ||
typedef Service<connection::v1::ConnectionService> ConnectionService; | ||
|
||
public: | ||
Connection(AuthSocket* session); | ||
|
||
uint32 HandleConnect(connection::v1::ConnectRequest const* request, connection::v1::ConnectResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation) override; | ||
uint32 HandleKeepAlive(NoData const* request) override; | ||
uint32 HandleRequestDisconnect(connection::v1::DisconnectRequest const* request) override; | ||
|
||
}; | ||
} | ||
} | ||
|
||
#endif // ConnectionService_h__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.