mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 07:15:49 +00:00
Added check for Stateview, added socket cancel to finish all connect, send and receive operations immediately
This commit is contained in:
parent
fbce8a946e
commit
f738950934
@ -84,6 +84,7 @@ void TClient::Disconnect(std::string_view Reason) {
|
||||
if (ec) {
|
||||
beammp_debugf("Failed to shutdown client socket: {}", ec.message());
|
||||
}
|
||||
mSocket.cancel();
|
||||
mSocket.close(ec);
|
||||
if (ec) {
|
||||
beammp_debugf("Failed to close client socket: {}", ec.message());
|
||||
|
@ -43,6 +43,8 @@ static sol::protected_function AddTraceback(sol::state_view StateView, sol::prot
|
||||
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName);
|
||||
|
||||
static std::optional<sol::function> GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName) {
|
||||
if (!StateView)
|
||||
return std::nullopt;
|
||||
auto Res = StateView.safe_script("return " + Handler, sol::script_pass_on_error);
|
||||
if (!Res.valid()) {
|
||||
beammp_errorf("invalid handler for event \"{}\". handler: \"{}\"", EventName, Handler);
|
||||
|
Loading…
x
Reference in New Issue
Block a user