public void SendEvent(AbstractEvent ev) { foreach (var session in GetSessions()) { session.SendEvent(ev); } }
private void SendEventLimited(AbstractEvent ev) { var msg = new JObject { { "type", "event" }, { "nr", Interlocked.Increment(ref _command_counter) }, { "id", ev.Name }, { "data", ev.Data }, }; SendText(JsonConvert.SerializeObject(msg)); }
//public void SendEventsToAllClients(Event[] events) //{ //} #endregion #region --> Events & Subscriptions /// <summary> /// Send the same event instance to all clients /// </summary> /// <param name="ev">The event instance to send</param> public void SendEvent(AbstractEvent ev) { if (ev == null) { return; } lock (_event_abos) { if (!_event_abos.ContainsKey(ev.Name) || _event_abos[ev.Name].ExpireTime < DateTime.Now) { return; } } lock (_event_timer) { _events_to_send.Enqueue(ev); SetEventTimer(); } }
private void RegisterEvent(string name, AbstractEvent c, Type type) { if (Events.ContainsKey(name)) { var existing = Events[name]; if (existing.Version > c.Version) // if version is equal, overwrite (due to compatibility). to ensure against overwriting, increase version number of the command. { return; } } Events[name] = new EventInfo { Name = name, InstructionSet = c.InstructionSet, Version = c.Version, Type = type, Description = c.Description, }; }
private void InitEvent(AbstractEvent ev) { ev.Session = this; }