A Remote Procedure Call framework for Godot C#.
$ dotnet add package RemSendA Remote Procedure Call framework for Godot C# using source generators.
MultiplayerApi by using the following code:RemSendService.Setup((SceneMultiplayer)Multiplayer, GetTree().Root);
Sending a method call to a remote peer:
[Rem(RemAccess.Any)]
public void SayWords(List<string> Words) {
foreach (string Word in Words) {
GD.Print(Word);
}
}
// Send SayWords to authority
SendSayWords(1, ["cat", "dog"]);
// Broadcast SayWords to all peers
BroadcastSayWords(["cat", "dog"]);
Requesting a result from a peer:
[Rem(RemAccess.PeerToAuthority)]
public int GetNumber() {
return 5;
}
// Send GetNumber to authority and await result for up to 10 seconds
int Number = await RequestGetNumber(1, TimeSpan.FromSeconds(10));
Getting the remote sender's peer ID:
[Rem(RemAccess.Any)]
public void RemoteHug([Sender] int SenderId) {
if (SenderId == 1) {
GD.Print("Thank you authority.");
}
else if (SenderId == Multiplayer.GetUniqueId()) {
GD.Print("*depression*");
}
else {
GD.Print("Thank you random peer.");
}
}
// Send RemoteHug to authority
SendRemoteHug(1);
SceneMultiplayer.SendBytes and SceneMultiplayer.PeerPacket, using them with RemSend is not recommended. However, you can still use RPCs.