Beispiel #1
0
        private async Task ReceiveLogon(NetworkMessage messsage)
        {
            CMsgClientLogonResponse response = messsage.Deserialize <CMsgClientLogonResponse>();

            if (response.eresult != 1)
            {
                await NetLog.InfoAsync($"Logon denied: {(Result)response.eresult}. Expect to disconnect").ConfigureAwait(false);
            }

            if (response.eresult == 1)
            {
                CellId = response.cell_id;
                var id = (messsage.Header as ClientHeader).SteamId;
                InstanceId = (long)response.client_instance_id;

                await NetLog.InfoAsync($"Logged in to Steam with session Id {SessionId} and steam ID {SteamId}").ConfigureAwait(false);

                _heartbeatCancel = new CancellationTokenSource();
                _heartBeatTask   = RunHeartbeatAsync(response.out_of_game_heartbeat_seconds * 1000, _heartbeatCancel.Token);
                await LoggedOn.TimedInvokeAsync(this, EventArgs.Empty, TaskTimeout, NetLog).ConfigureAwait(false);
            }
            else
            {
                await LoginRejected.InvokeAsync(this, new LoginRejectedEventArgs(response.client_supplied_steamid, (Result)response.eresult, (Result)response.eresult_extended, response.email_domain)).ConfigureAwait(false);
            }
        }
Beispiel #2
0
        private async Task ReceiveLogOff(CMsgClientLoggedOff loggedOff)
        {
            await NetLog.InfoAsync($"Logged off: {(Result)loggedOff.eresult} ({loggedOff.eresult})").ConfigureAwait(false);

            await LoggedOff.InvokeAsync(this, new LogOffEventArgs((Result)loggedOff.eresult));

            _gracefulLogoff = true;
        }
Beispiel #3
0
 private async Task AutoLoginToFriends(CMsgClientLogonResponse response)
 {
     if (response.eresult == 1 && GetConfig <SteamNetworkConfig>().AutoLoginFriends&& SteamId.FromCommunityId(response.client_supplied_steamid).IsIndividualAccount)
     {
         await NetLog.InfoAsync("Logging into friends").ConfigureAwait(false);
         await SetPersonaStateAsync(PersonaState.Online).ConfigureAwait(false);
     }
 }
Beispiel #4
0
        private async Task LoginAsync(LoginInfo info)
        {
            uint instance = 0;

            if (info.AccountId != 0)
            {
                instance = 2;
            }
            else if (info.AccountType != AccountType.AnonUser)
            {
                instance = 1;
            }

            await NetLog.InfoAsync($"Logging in as {info.Username ?? (instance == 0 ? "an anonymous user" : "a console user")}").ConfigureAwait(false);

            byte[] machineId = await HardwareUtils.GetMachineId().ConfigureAwait(false); // while we set up the logon object, we will start to get the machine ID

            var body = new CMsgClientLogon
            {
                protocol_version = 65579,
                client_os_type   = (uint)(info.AccountId == 0 ? HardwareUtils.GetCurrentOsType() : OsType.PS3),
                client_language  = GetConfig <SteamNetworkConfig>().Language.GetApiLanguageCode(),
                cell_id          = (uint)GetConfig <SteamNetworkConfig>().CellId,
            };

            if (machineId != null && machineId.Length != 0)
            {
                body.machine_id = machineId;
            }

            if (info.AccountType != AccountType.AnonUser)
            {
                body.account_name                 = info.Username;
                body.password                     = info.Password;
                body.should_remember_password     = info.ShouldRememberPassword;
                body.steam2_ticket_request        = info.RequestSteam2Ticket;
                body.two_factor_code              = info.TwoFactorCode;
                body.auth_code                    = info.AuthCode;
                body.login_key                    = info.LoginKey;
                body.sha_sentryfile               = info.SentryFileHash;
                body.eresult_sentryfile           = (int)(info.SentryFileHash is null ? Result.FileNotFound : Result.OK);
                body.client_package_version       = 1771;
                body.obfustucated_private_ip      = (uint)(GetConfig <SteamNetworkConfig>().LoginId < 0 ? LocalIp.ToUInt32() ^ _obfuscationMask : GetConfig <SteamNetworkConfig>().LoginId);
                body.supports_rate_limit_response = true;
            }

            var logon = NetworkMessage
                        .CreateProtobufMessage(MessageType.ClientLogon, body)
                        .WithClientInfo(new SteamId(info.AccountId, GetConfig <SteamNetworkConfig>().DefaultUniverse, info.AccountType, instance), 0);

            await SendAsync(logon.Serialize()).ConfigureAwait(false);
        }
Beispiel #5
0
        private async Task ConnectInternalAsync()
        {
            _connectCancellationToken = new CancellationTokenSource();
            Socket.SetCancellationToken(_connectCancellationToken.Token);
            if (Socket is IWebSocketClient webSocketClient)
            {
                CurrentServer = await GetWebSocketConnectionServerAsync().ConfigureAwait(false);

                await NetLog.InfoAsync($"Connecting to WebSocket {CurrentServer}").ConfigureAwait(false);

                await webSocketClient.ConnectAsync(new Uri($"wss://{CurrentServer.ToString()}/cmsocket/")).ConfigureAwait(false);
            }
            else
            {
                CurrentServer = await GetConnectionServerAsync().ConfigureAwait(false);

                await NetLog.InfoAsync($"Connecting to endpoint {CurrentServer}").ConfigureAwait(false);

                await Socket.ConnectAsync(CurrentServer.GetIPEndPoint()).ConfigureAwait(false);
            }
        }