internal Task <bool> SendTracer(TextWriter log = null) { var msg = GetTracerMessage(false); msg = LoggingMessage.Create(log, msg); return(QueueDirectAsync(msg, ResultProcessor.Tracer)); }
void Handshake(PhysicalConnection connection, TextWriter log) { multiplexer.LogLocked(log, "Server handshake"); if (connection == null) { multiplexer.Trace("No connection!?"); return; } Message msg; string password = multiplexer.RawConfig.Password; if (!string.IsNullOrWhiteSpace(password)) { multiplexer.LogLocked(log, "Authenticating (password)"); msg = Message.Create(-1, CommandFlags.FireAndForget, RedisCommand.AUTH, (RedisValue)password); msg.SetInternalCall(); WriteDirectOrQueueFireAndForget(connection, msg, ResultProcessor.DemandOK); } if (multiplexer.CommandMap.IsAvailable(RedisCommand.CLIENT)) { string name = multiplexer.ClientName; if (!string.IsNullOrWhiteSpace(name)) { name = nameSanitizer.Replace(name, ""); if (!string.IsNullOrWhiteSpace(name)) { multiplexer.LogLocked(log, "Setting client name: {0}", name); msg = Message.Create(-1, CommandFlags.FireAndForget, RedisCommand.CLIENT, RedisLiterals.SETNAME, (RedisValue)name); msg.SetInternalCall(); WriteDirectOrQueueFireAndForget(connection, msg, ResultProcessor.DemandOK); } } } var connType = connection.Bridge.ConnectionType; if (connType == ConnectionType.Interactive) { multiplexer.LogLocked(log, "Auto-configure..."); AutoConfigure(connection); } multiplexer.LogLocked(log, "Sending critical tracer: {0}", connection.Bridge); var tracer = GetTracerMessage(true); tracer = LoggingMessage.Create(log, tracer); WriteDirectOrQueueFireAndForget(connection, tracer, ResultProcessor.EstablishConnection); // note: this **must** be the last thing on the subscription handshake, because after this // we will be in subscriber mode: regular commands cannot be sent if (connType == ConnectionType.Subscription) { var configChannel = multiplexer.ConfigurationChangedChannel; if (configChannel != null) { msg = Message.Create(-1, CommandFlags.FireAndForget, RedisCommand.SUBSCRIBE, (RedisChannel)configChannel); WriteDirectOrQueueFireAndForget(connection, msg, ResultProcessor.TrackSubscriptions); } } multiplexer.LogLocked(log, "Flushing outbound buffer"); connection.Flush(); }