registerFunction method
Implementation
RawNetworkerPipe registerFunction(
int function, {
String? name,
bool canRunLocally = false,
RpcNetworkerMode mode = RpcNetworkerMode.authority,
}) {
if (_functionNames.contains((function, name))) {
throw ArgumentError('Function $function already registered');
}
final pipe = RawNetworkerPipe();
final rpcFunction = RpcFunction(
canRunLocally: canRunLocally,
mode: mode,
pipe: pipe,
);
functions[function] = rpcFunction;
if (name != null) {
_functionNames.add((function, name));
}
pipe.write.listen((packet) => sendMessage(RpcNetworkerPacket(
function: function,
data: packet.data,
channel: packet.channel,
)));
return pipe;
}