Esempio n. 1
0
        /*----< invokes delegate bound to cmd key >--------------------*/

        /*
         *  returns procError message if cmd doesn't have a bound lambda
         */
        public Msg doCommand(Msg.Command cmd, Msg msg)
        {
            if (dispather.Keys.Contains(cmd))
            {
                return(dispather[cmd].Invoke(msg));
            }
            else
            {
                Msg reply = new Msg(Msg.MessageType.procError);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = msg.command;
                return(reply);
            }
        }
Esempio n. 2
0
        /*----< add lambda, bound to Func delegate, keyed to msg >-----*/

        public void addCommand(Msg.Command cmd, Func <Msg, Msg> action)
        {
            dispather[cmd] = action;
        }