/// <summary>
/// Logs onto the Steam network as a persistent game server.
/// The client should already have been connected at this point.
/// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
/// </summary>
/// <param name="details">The details to use for logging on.</param>
/// <exception cref="ArgumentNullException">No logon details were provided.</exception>
/// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
public void LogOn(LogOnDetails details)
{
if (details == null)
{
throw new ArgumentNullException("details");
}
if (string.IsNullOrEmpty(details.Username) || string.IsNullOrEmpty(details.Password))
{
throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
}
var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);
SteamID gsId = new SteamID(0, 0, Client.ConnectedUniverse, EAccountType.GameServer);
logon.ProtoHeader.client_sessionid = 0;
logon.ProtoHeader.steamid = gsId.ConvertToUInt64();
uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);
logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;
logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
logon.Body.client_os_type = ( uint )Utils.GetOSType();
logon.Body.game_server_app_id = ( int )details.AppID;
logon.Body.machine_id = Utils.GenerateMachineID();
logon.Body.account_name = details.Username;
logon.Body.password = details.Password;
this.Client.Send(logon);
}