I thought about that a bit. To do it, we would still need to create a setter to modify the context since ideally we don't want anyone to mess with it directly in case it changes in the future. Even then, it would either store const char*, which would only work if the caller guaranteed the string didn't go out of scope ever, or have to store a char array, which increases memory footprint. With const char*, if they user used a temp string (e.g., wanted to use sprintf() or something) and it went out of scope, future calls to Authenticate() to handle reconnects would crash.
I figured this was the clearest and safest solution, and it's consistent with the existing ConnectTo() call.
I thought about that a bit. To do it, we would still need to create a setter to modify the context since ideally we don't want anyone to mess with it directly in case it changes in the future. Even then, it would either store
const char*
, which would only work if the caller guaranteed the string didn't go out of scope ever, or have to store a char array, which increases memory footprint. Withconst char*
, if they user used a temp string (e.g., wanted to usesprintf()
or something) and it went out of scope, future calls toAuthenticate()
to handle reconnects would crash.I figured this was the clearest and safest solution, and it's consistent with the existing
ConnectTo()
call.