Usage of Command giving Issue after Adding Classes giving Unknown Request

Feb 20, 2014 at 7:03 AM
Hi kerryjiang,
I switch case example works fine.

when I change as per the Usage of Command

I add the 2 class
ADD & MULT
public class ADD : CommandBase<AppSession, StringRequestInfo>
        {
            public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo)
            {
                session.Send(requestInfo.Parameters.Select(p => Convert.ToInt32(p)).Sum().ToString());
            }
        }

        public class MULT : CommandBase<AppSession, StringRequestInfo>
        {
            public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo)
            {
                var result = 1;

                foreach (var factor in requestInfo.Parameters.Select(p => Convert.ToInt32(p)))
                {
                    result *= factor;
                }

                session.Send(result.ToString());
            }
        }
Removed
//appServer.NewRequestReceived += new RequestHandler<AppSession, StringRequestInfo>(appServer_NewRequestReceived);
now When I'm running it it says Unknown Request: ADD.

That's obvious, you mentioned:

__ For a instance, you can define a class named "ADD" to process the requests with __
__ the requestInfo's key equals "ADD": __

This is what I'm unclear about, so you mean to use/change it in the switch case?

However this below code is working as I'm following a traditional way, but I don't think this is what you suggested.

The Switch Case
case ("ADD"):
                    ADD obj = new ADD();
                    obj.ExecuteCommand(session, requestInfo);
Un Commenting
appServer.NewRequestReceived += new RequestHandler<AppSession, StringRequestInfo>(appServer_NewRequestReceived);
If you can clear my doubt.

Thanks,
Feb 20, 2014 at 7:20 AM
Please compare the projects in the QuickStart and find the differences.