Generic Command

May 7, 2013 at 12:41 AM
I am trying to use the command framework like the example seem here.

If I create something like the ADD command on the example, I have to turn off the event handling NewRequestReceived as suggested in the example.

That creates a little problem, now I can handle "generic" commands what I mean by that, is that the app I am building would hand off the command execution to some other service when it can't find it in the local commands.

Lets say we have the ADD command, and the user types SUBTRACT, which is located in some other service, what I would like to do is instead of just throwing an error, I would like to send this to some resolver service, that will try to find someone that does the subtraction, execute it and return the result whenever that is done.

In the normal way of resolving the commands using the switch statement, I can use "default" and there I would have the possibility of handling the "SUBTRACT" as I described above.

So my question is, is there a way of creating a command class with a special name or anything like that, in a way that all requests would be handled by it, except when there is a matching command class?

May 8, 2013 at 3:06 PM
If I understand you clearly, the AppSession's virtual method "HandleUnknownRequest(TRequestInfo requestInfo)" is designed for this purpose, you can override it in your session implementation.