ServiceStack.Redis.RedisPubSubServer.HandleFailover C# (CSharp) Method

HandleFailover() private method

private HandleFailover ( IRedisClientsManager clientsManager ) : void
clientsManager IRedisClientsManager
return void
        private void HandleFailover(IRedisClientsManager clientsManager)
        {
            try
            {
                if (OnFailover != null)
                    OnFailover(this);

                if (masterClient != null)
                {
                    //New thread-safe client with same connection info as connected master
                    using (var currentlySubscribedClient = ((RedisClient)masterClient).CloneClient())
                    {
                        Interlocked.CompareExchange(ref doOperation, Operation.Reset, doOperation);
                        foreach (var channel in Channels)
                        {
                            currentlySubscribedClient.PublishMessage(channel, ControlCommand.Control);
                        }
                    }
                }
                else
                {
                    Restart();
                }
            }
            catch (Exception ex)
            {
                if (this.OnError != null) this.OnError(ex);
                Log.Warn("Error trying to UnSubscribeFromChannels in OnFailover. Restarting...", ex);
                Restart();
            }
        }