I'm trying to come up with a nice system for syncing RPC calls on a client-server system (in C#).
Currently a call looks something like this:
static public void swapItems(int itemIndex1, int itemIndex2)
{
sendRPC("swapItems", Network.player, itemIndex1, itemIndex2);
}
protected void swapItems(NetworkPlayer user, int itemIndex1, int itemIndex2)
{
User tempUser = mUserMap[user];
Item item1 = tempUser.getItem(itemIndex1);
Item item2 = tempUser.getItem(itemIndex2);
tempUser.swapItems(item1, item2);
}
This system works okay, since the call wrapper is strongly typed. But there are still a few problems. One is that the actual RPC call isn't strongly typed, so if I change the definition on the server side, the compiler doesn't flag the RPC call as invalid. The second, is that it basically doubles the code required to create all the call wrappers.
I'm wondering if there is an easier, cleaner way to create the call wrapper. One solution would be dynamically creating the code based on the server's call definition, but that seems like a bit of a hassle to work into the work-flow.
Anyone have a better idea, and/or a library that already does this?