Пример #1
0
        public static void dispatchEvent(WebSocketHandler ws, KSPEvents ev, String eventData, String subEventID)
        {
            if (!_cachedEvents.ContainsKey(ev)) _cachedEvents.Add(ev, new Dictionary<String, String>());

            if (!_cachedEvents[ev].ContainsKey(subEventID)) _cachedEvents[ev].Add(subEventID, eventData);
            else _cachedEvents[ev][subEventID] = eventData;

            getSubscribers(ev).ForEach((WSClient client) =>
            {
                if (subscribedSubEvents[ev].ContainsKey(client.ID))
                {
                    if (subscribedSubEvents[ev][client.ID].Contains(subEventID))
                    {
                        ws.SendTo(client.ID, eventData);
                    }
                }
            });
        }
Пример #2
0
 public EventHandler(KSPAlternateController parent)
 {
     this.parent = parent;
     this.ws = WebSocketHandler.me;
 }
Пример #3
0
        public static void dispatchEvent(WebSocketHandler ws, KSPEvents ev, String eventData)
        {
            if (!_cachedEvents.ContainsKey(ev)) _cachedEvents.Add(ev, eventData);
            else _cachedEvents[ev] = eventData;

            getSubscribers(ev).ForEach((WSClient client) => {
                ws.SendTo(client.ID, eventData);
            });
        }
 protected override void OnOpen()
 {
     if (me == null) me = this;
     new WSClient(ID);
 }