Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle internal immediate forced disconnects #908

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Server/Components/LegacyNetwork/legacy_network_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ void RakNetLegacyNetwork::OnRakNetDisconnect(RakNet::PlayerIndex rid, PeerDiscon
networkEventDispatcher.dispatch(&NetworkEventHandler::onPeerDisconnect, *player, reason);
}

void RakNetLegacyNetwork::OnCloseConnection(RakNet::RakPeerInterface* peer, RakNet::PlayerID playerId)
{
auto playerIndex = peer->GetIndexFromPlayerID(playerId);
OnRakNetDisconnect(playerIndex, PeerDisconnectReason_Kicked);
}

template <size_t ID>
void RakNetLegacyNetwork::RPCHook(RakNet::RPCParameters* rpcParams, void* extra)
{
Expand Down Expand Up @@ -870,6 +876,8 @@ void RakNetLegacyNetwork::start()
const String get = "https://api.open.mp/0.3.7/announce/" + std::to_string(port);
core->requestHTTP4(new AnnounceHTTPResponseHandler(core), HTTPRequestType::HTTPRequestType_Get, get.data());
}

rakNetServer.AttachPlugin(this);
}

rakNetServer.StartOccasionalPing();
Expand Down
4 changes: 3 additions & 1 deletion Server/Components/LegacyNetwork/legacy_network_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <raknet/GetTime.h>
#include <raknet/RakNetworkFactory.h>
#include <raknet/RakServerInterface.h>
#include <raknet/PluginInterface.h>
#include <raknet/StringCompressor.h>

using namespace Impl;
Expand All @@ -31,7 +32,7 @@ static const StaticArray<StringView, 2> ProtectedRules = {

class Core;

class RakNetLegacyNetwork final : public Network, public CoreEventHandler, public PlayerConnectEventHandler, public PlayerChangeEventHandler, public INetworkQueryExtension
class RakNetLegacyNetwork final : public Network, public CoreEventHandler, public PlayerConnectEventHandler, public PlayerChangeEventHandler, public INetworkQueryExtension, public RakNet::PluginInterface
{
private:
ICore* core = nullptr;
Expand Down Expand Up @@ -290,6 +291,7 @@ class RakNetLegacyNetwork final : public Network, public CoreEventHandler, publi
void start();

void OnRakNetDisconnect(RakNet::PlayerIndex rid, PeerDisconnectReason reason);
void OnCloseConnection(RakNet::RakPeerInterface* peer, RakNet::PlayerID playerId) override;

void onPlayerScoreChange(IPlayer& player, int score) override
{
Expand Down
Loading