public void Dispose() { try { foreach (var entry in local.Subcriptions) { var info = local.GetSubscriptionInfo(entry.Key); if (info != null) { RemoveSubscriptionFromRedis(info); } } } catch (Exception ex) { Log.Warn("Error trying to remove local.Subcriptions during Dispose()...", ex); } if (RedisPubSub != null) { RedisPubSub.Dispose(); } if (local != null) { local.Dispose(); } RedisPubSub = null; local = null; }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; WaitBeforeNextRestart = TimeSpan.FromMilliseconds(2000); local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null ? appHost.GetPlugin<ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; HouseKeepingInterval = feature.HouseKeepingInterval; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; KeepAliveRetryAfterMs = 2000; local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null?appHost.GetPlugin <ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; WaitBeforeNextRestart = TimeSpan.FromMilliseconds(2000); local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyUpdate = HandleOnUpdate, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null?appHost.GetPlugin <ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; HouseKeepingInterval = feature.HouseKeepingInterval; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public RedisServerEvents(IRedisPubSubServer redisPubSub) { this.RedisPubSub = redisPubSub; this.clientsManager = redisPubSub.ClientsManager; redisPubSub.OnInit = OnInit; redisPubSub.OnError = ex => Log.Error("Exception in RedisServerEvents: " + ex.Message, ex); redisPubSub.OnMessage = HandleMessage; KeepAliveRetryAfterMs = 2000; local = new MemoryServerEvents { NotifyJoin = HandleOnJoin, NotifyLeave = HandleOnLeave, NotifyHeartbeat = HandleOnHeartbeat, Serialize = HandleSerialize, }; var appHost = HostContext.AppHost; var feature = appHost != null ? appHost.GetPlugin<ServerEventsFeature>() : null; if (feature != null) { Timeout = feature.IdleTimeout; OnSubscribe = feature.OnSubscribe; OnUnsubscribe = feature.OnUnsubscribe; NotifyChannelOfSubscriptions = feature.NotifyChannelOfSubscriptions; } }
public async void Start() { _values = new List <string>(); _client = _clientsManager.GetClient(); Console.WriteLine($"starting up {GetResults()}"); _pubSubServer = _clientsManager.CreatePubSubServer(CHANNEL_RECIEVE, RegisterResults).Start(); Send(CHANNEL_START, "now collecting results"); await Task.Delay(TimeSpan.FromSeconds(10)); Stop(); }
private void button1_Click(object sender, EventArgs e) { /// stop if (redisPubSub != null) { logEvent("Stopping LightBot!", true); redisPubSub.Stop(); redisPubSub = null; pubsubThread = null; toolStripStatusLabel2.Text = "Disconnected"; } }
private void pubsubRunner(ILocalHueClient client) { Console.WriteLine("Started pubsub"); var clientsManager = new PooledRedisClientManager("client:3rogK4bOMIAFDSJ8P0FqjNYxwDIk6UatbbMlUVV7uySHnPhxhrh0IFIwnf3ZEjo@pubsub.huelightbot.com"); redisPubSub = new RedisPubSubServer(clientsManager, textBox1.Text) { OnMessage = (channel, msg) => HandleOnMessage(channel, msg), OnError = (ex) => HandleOnError(ex) }.Start(); return; }
public void Dispose() { if (RedisPubSub != null) { RedisPubSub.Dispose(); } if (local != null) { local.Dispose(); } RedisPubSub = null; local = null; }
public void Stop() { if (_client != null) { var results = GetResults(); Console.WriteLine($"results: {results}"); Send(CHANNEL_END, $"results are in {results}"); _client.Dispose(); _client = null; } if (_pubSubServer != null) { _pubSubServer.Stop(); _pubSubServer.Dispose(); _pubSubServer = null; } _values = null; }
public void Dispose() { if (RedisPubSub != null) RedisPubSub.Dispose(); if (local != null) local.Dispose(); RedisPubSub = null; local = null; }