コード例 #1
0
        private async UniTaskVoid StartServer()
        {
            try
            {
                Uri baseUri = SpotifyConfiguration.ServerConfiguration.Uri;
                int port    = SpotifyConfiguration.ServerConfiguration.Port;

                EmbedIOAuthServer server = new EmbedIOAuthServer(baseUri, port);
                await server.Start();

                server.AuthorizationCodeReceived += (sender, response) =>
                {
                    server.Stop();
                    server.Dispose();
                    responseCode = response.Code;
                    return(null);
                };

                OnServerInitialized.Raise();

                await UniTask.WaitUntil(() => !string.IsNullOrEmpty(responseCode));

                Client.FromAuthorizationCode(responseCode).Forget();
                Destroy(gameObject);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }