Пример #1
0
 private SpotifySession([NotNull] Inner inner,
                        CancellationToken closedToken,
                        [CanBeNull] string address)
 {
     recvNonce        = 0;
     sendNonce        = 0;
     this.inner       = inner;
     this.closedToken = closedToken;
     this.conn        = SpotifyConnection.Create(
         inner.Conf,
         address);
     this.keys = new DiffieHellman(new System.Random());
     Debug.WriteLine($"Created new session! deviceId: {inner.DeviceId}, ap: {address}");
     Current = this;
 }
Пример #2
0
        private void Reconnect()
        {
            lock (reconnectionListeners)
            {
                foreach (var reconnectionListener in reconnectionListeners)
                {
                    reconnectionListener.OnConnectionDropped();
                }
            }

            if (conn != null)
            {
                conn.Result.Conn.Close();
                receiver.Stop();
            }

            try
            {
                conn = SpotifyConnection.Create(inner.Conf);
                Connect();
                AuthenticatePartial(new LoginCredentials
                {
                    Typ      = apWelcome.ReusableAuthCredentialsType,
                    Username = apWelcome.CanonicalUsername,
                    AuthData = apWelcome.ReusableAuthCredentials
                }, true);
                Debug.WriteLine($"Re-authenticated as {apWelcome.CanonicalUsername}!");
                lock (reconnectionListeners)
                {
                    foreach (var reconnectionListener in reconnectionListeners)
                    {
                        reconnectionListener.OnConnectionEstablished();
                    }
                }
            }
            catch (Exception x)
            {
                Debugger.Break();
            }
        }