public static BaseCommand ToBaseCommand(this CommandAuthChallenge value) { return(new BaseCommand { type = BaseCommand.Type.AuthChallenge, authChallenge = value }); }
public static ReadOnlySequence <byte> NewAuthChallenge(string authMethod, AuthData brokerData, int clientProtocolVersion) { var challenge = new CommandAuthChallenge(); // If the broker supports a newer version of the protocol, it will anyway advertise the max version that the // client supports, to avoid confusing the client. var versionToAdvertise = Math.Min(Enum.GetValues(typeof(ProtocolVersion)).Cast <int>().Max(), clientProtocolVersion); challenge.ProtocolVersion = versionToAdvertise; challenge.Challenge = new AuthData { auth_data = brokerData.auth_data, AuthMethodName = authMethod }; //var challenge = challenge.Challenge().Build(); return(Serializer.Serialize(challenge.ToBaseCommand())); }