A Remote Procedure Call framework for Godot C# using source generators.
- Call source-generated RPCs with static typing and optimal performance.
- Request and return values from RPCs.
- Send variant-incompatible values with MemoryPack.
- Extra access enum (peer -> authority).
- Fully compatible with async / Tasks.
- Created for use in a real MMORPG.
- Install RemSend through NuGet.
- Connect RemSend to your
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 is 1) {
GD.Print("Thank you authority.");
}
else if (SenderId is 0) {
GD.Print("*depression*");
}
else {
GD.Print("Thank you random peer.");
}
}
// Send RemoteHug to authority
SendRemoteHug(1);
- Since RemSend uses
SceneMultiplayer.SendBytes
andSceneMultiplayer.PeerPacket
, using them with RemSend is not recommended. However, you can still use RPCs. - RemSend does not support GDScript or C++. It can only be used with C#. Other languages can use RPCs instead.
- GodotSharp.SourceGenerators for help with source generation for members with attributes.