示例#1
0
        internal Action SubscribeToAll(Action <ScriptEventData> callback)
        {
            Next();

            ThisScript.SimpleLog(LogLevel.Info, "Subscribing to " + Current.Events.Length + " events: " + string.Join(", ", Current.Events));

            Action <ScriptEventData> wrappedCallback = callback;

            foreach (string eventName in Current.Events)
            {
                if (ThisScript.DebugEnabled())
                {
                    var sub = ThisScript.SubscribeToSimpleEvent(eventName, (ScriptEventData data) =>
                    {
                        ThisScript.SimpleLog(LogLevel.Info, "Received event " + eventName);
                        wrappedCallback(data);
                    });
                    Current.Unsubscribe += sub.Unsubscribe;
                }
                else
                {
                    var sub = ThisScript.SubscribeToSimpleEvent(eventName, wrappedCallback);
                    Current.Unsubscribe += sub.Unsubscribe;
                }
            }
            return(Current.Unsubscribe);
        }
示例#2
0
        internal void SendToAll(SimpleData data)
        {
            Next();

            ThisScript.SimpleLog(LogLevel.Info, "Sending " + Current.Events.Length + " events: " + string.Join(", ", Current.Events));

            foreach (string eventName in Current.Events)
            {
                ThisScript.PostSimpleEvent(eventName, data);
            }
        }