registerFunction method
inherited
Implementation
RawNetworkerPipe registerFunction(
int function, {
bool canRunLocally = false,
RpcNetworkerMode mode = RpcNetworkerMode.authority,
}) {
if (_functions.containsKey(function)) return _functions[function]!.pipe;
final pipe = RawNetworkerPipe();
final rpcFunction = RpcFunction(
canRunLocally: canRunLocally,
mode: mode,
pipe: pipe,
);
_functions[function] = rpcFunction;
pipe.write.listen((packet) => sendMessage(
RpcNetworkerPacket(
function: function,
data: packet.data,
channel: isServer ? defaultReceiverChannel : packet.channel,
),
isServer ? packet.channel : defaultReceiverChannel));
return pipe;
}