I am trying to make an Assembly that allows me to do networking for video games, the problem i am facing is having a way to call methods on both sides of the connection so what i thought of doing is to have a List<Action>
to store the methods and be able to call them through the network with a index number (for packet weight)
The part that is giving me a bad time is:
How to register those methods in the list so the list is the exact same on every machines
and workflow wise accessing them efficiently (being able to use autocomplete to know what "Command" method is accessible) but i'm facing several problems:
-
The
List<Action>
has to have a sort of hardcoded order so its the same on every machines so no runtime initialisation -
Workflow wise it would good be able to get the methods by name in a autocomplete kind of way
-
It has to be loosely coupled in a way that i can compile to a .dll and use it in a other project
For now i tried those things:
-
To register the methods i tried Reflection and Attributes, i tag the methods with an attribute and at runtime i look trought the Assembly for those and add them to the List, i'm hoping the order won't differ from a machine to an other
-
I didn't found a good way to get a method other than iterating through the List by name, i could make a widget that generate some code like an enum but i'd like to avoid code generation as much as possible
-
For the loose coupling the Reflection + Attributes combo could do the trick i'd have to look through the whole solution instead, i still need to find a way to get the methods from the list efficiently
Any bit of wisdom would be appreciated
Aucun commentaire:
Enregistrer un commentaire