Beispiel #1
0
        private IUpdateEvent UserActionHandler(ref EventArgs ea, IDictionary <string, object> globals)
        {
            IUserEvent ue    = (IUserEvent)ea;
            var        label = ue.GetEventType();

            ea = null;

            scheduler.Suspend();
            scheduler.Launch("#On" + label + "Event");

            return(null);
        }
Beispiel #2
0
        internal IUpdateEvent HandleCommand(Command cmd,
                                            IDictionary <string, object> globals)
        {
            if (ChatRuntime.LOG_FILE != null)
            {
                WriteToLog(cmd);
            }

            cmd.Resolve(globals);

            if (cmd is ISendable)
            {
                if (cmd.GetType() == typeof(Wait))
                {
                    if (cmd.delay > Util.INFINITE) // non-infinite WAIT?
                    {
                        // just pause internally, no event needs to be fired
                        ComputeNextEventTime(cmd);
                        return(null);
                    }
                    scheduler.Suspend();          // suspend on infinite WAIT
                }
                else if (cmd is Ask)
                {
                    scheduler.prompt = (Ask)cmd;
                    scheduler.Suspend();          // wait on ChoiceEvent
                }
                else
                {
                    ComputeNextEventTime(cmd);   // compute delay for next cmd
                }

                return(new UpdateEvent(cmd.Resolve(globals))); // fire event
            }
            else if (cmd is Find)
            {
                scheduler.Completed(false);
                runtime.FindAsync((Find)cmd);      // finish, then do the Find
            }

            return(null);
        }