Loading net/include/net/rpc_system.hpp +7 −4 Original line number Diff line number Diff line Loading @@ -5,10 +5,13 @@ #include <net/index.hpp> #include <net/network_types.hpp> #define RPC_RELIABLE(function, peer, ...) \ net::RPCSystem::call_remote(this, #function, peer, net::ReliabilityMode::RELIABLE, __VA_ARGS__) #define RPC_UNRELIABLE(function, peer, ...) \ net::RPCSystem::call_remote(this, #function, peer, net::ReliabilityMode::UNRELIABLE, __VA_ARGS__) // RPC macros for remote procedure calls // Note: When registering functions that can be called via RPC, the first parameter // will always be ConnectionId representing the sender. #define RPC_RELIABLE(function, target, ...) \ net::RPCSystem::call_remote(this, #function, target, net::ReliabilityMode::RELIABLE, __VA_ARGS__) #define RPC_UNRELIABLE(function, target, ...) \ net::RPCSystem::call_remote(this, #function, target, net::ReliabilityMode::UNRELIABLE, __VA_ARGS__) namespace net { Loading net/src/rpc_system.cpp +23 −1 Original line number Diff line number Diff line Loading @@ -11,9 +11,19 @@ namespace net des->container(context_item_path, 32, [](auto& s, std::string& str) { s.text1b(str, 250); }); if (context_item_path.empty()) { LOG(LSL_ERROR, "[RPCSystem] Received RPC packet with empty context item path"); return; } std::string function_name; des->text1b(function_name, 250); if (function_name.empty()) { LOG(LSL_ERROR, "[RPCSystem] Received RPC packet with empty function name"); return; } std::vector<uint8_t> param_data; call_function_local(context_item_path, function_name, des, from); Loading Loading @@ -68,7 +78,19 @@ namespace net auto des = static_cast<Deserializer*>(deserializer); const auto context_item = root()->locate<com::ContextItem>(context_item_path); const auto function = context_item->reflection()->functions().at(function_name); if (!context_item) { LOG(LSL_ERROR, "[RPCSystem] Context item not found"); return; } auto& functions = context_item->reflection()->functions(); if (!functions.contains(function_name)) { LOG(LSL_ERROR, "[RPCSystem] Function " << function_name << " not found"); return; } const auto& function = functions.at(function_name); std::vector<com::Reflection::ValuePtr> params; params.push_back(com::make_value<com::Reflection::ValueINT>(from_id)); // First parameter is the sender's connection ID Loading Loading
net/include/net/rpc_system.hpp +7 −4 Original line number Diff line number Diff line Loading @@ -5,10 +5,13 @@ #include <net/index.hpp> #include <net/network_types.hpp> #define RPC_RELIABLE(function, peer, ...) \ net::RPCSystem::call_remote(this, #function, peer, net::ReliabilityMode::RELIABLE, __VA_ARGS__) #define RPC_UNRELIABLE(function, peer, ...) \ net::RPCSystem::call_remote(this, #function, peer, net::ReliabilityMode::UNRELIABLE, __VA_ARGS__) // RPC macros for remote procedure calls // Note: When registering functions that can be called via RPC, the first parameter // will always be ConnectionId representing the sender. #define RPC_RELIABLE(function, target, ...) \ net::RPCSystem::call_remote(this, #function, target, net::ReliabilityMode::RELIABLE, __VA_ARGS__) #define RPC_UNRELIABLE(function, target, ...) \ net::RPCSystem::call_remote(this, #function, target, net::ReliabilityMode::UNRELIABLE, __VA_ARGS__) namespace net { Loading
net/src/rpc_system.cpp +23 −1 Original line number Diff line number Diff line Loading @@ -11,9 +11,19 @@ namespace net des->container(context_item_path, 32, [](auto& s, std::string& str) { s.text1b(str, 250); }); if (context_item_path.empty()) { LOG(LSL_ERROR, "[RPCSystem] Received RPC packet with empty context item path"); return; } std::string function_name; des->text1b(function_name, 250); if (function_name.empty()) { LOG(LSL_ERROR, "[RPCSystem] Received RPC packet with empty function name"); return; } std::vector<uint8_t> param_data; call_function_local(context_item_path, function_name, des, from); Loading Loading @@ -68,7 +78,19 @@ namespace net auto des = static_cast<Deserializer*>(deserializer); const auto context_item = root()->locate<com::ContextItem>(context_item_path); const auto function = context_item->reflection()->functions().at(function_name); if (!context_item) { LOG(LSL_ERROR, "[RPCSystem] Context item not found"); return; } auto& functions = context_item->reflection()->functions(); if (!functions.contains(function_name)) { LOG(LSL_ERROR, "[RPCSystem] Function " << function_name << " not found"); return; } const auto& function = functions.at(function_name); std::vector<com::Reflection::ValuePtr> params; params.push_back(com::make_value<com::Reflection::ValueINT>(from_id)); // First parameter is the sender's connection ID Loading