I'm working on a multi-threaded tcp game server (using ICS). I'm looking at potentially hundreds of different possible commands coming from the clients. For example the command 'get_skills' will tell the server to stuff the db table Skills into a JSON and send it back to the client. Other incoming commands will have a data component like, 'train_skill:1'
Where I'm having major brain hemorrhages:
With so many possible commands coming in from the client, what will be the best way to route these commands to the proper function/procedure? Something like a lookup table would be nice so that I don't have to hard-code all these commands.
I could do a case statement but that could end up being huge and I'd have to convert the incoming command from a string to an integer and deal with that mess.
I could do a massive if-then-else block but that would be even more nightmarish.
I looked at the options listed here: Delphi: Call a function whose name is stored in a string
The only one of those solutions that even looked viable was the superobject and after downloading it and screwing around for a couple of hours trying to get it to work, I gave up on that.
I looked at the dispatchtable solution and could not figure out how to pass parameters to the procedures. Apparently TProc, TProcedure and procedure are 3 different things that don't play nice with each other.
Other than that, none of them seemed to have the ability or option to pass data to a procedure which would be essential.