File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Assets/Plugins/Web3AuthSDK Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,7 @@ private void sessionTimeOutAPI()
470470 }
471471
472472 private async Task < string > createSession ( string data , long sessionTime ) {
473+ TaskCompletionSource < string > createSessionResponse = new TaskCompletionSource < string > ( ) ;
473474 var newSessionKey = KeyStoreManagerUtils . generateRandomSessionKey ( ) ;
474475 var ephemKey = KeyStoreManagerUtils . getPubKey ( newSessionKey ) ;
475476 var ivKey = KeyStoreManagerUtils . generateRandomBytes ( ) ;
@@ -506,17 +507,19 @@ private async Task<string> createSession(string data, long sessionTime) {
506507 try
507508 {
508509 this . Enqueue ( ( ) => KeyStoreManagerUtils . savePreferenceData ( KeyStoreManagerUtils . SESSION_ID , newSessionKey ) ) ;
510+ createSessionResponse . SetResult ( newSessionKey ) ;
509511 }
510512 catch ( Exception ex )
511513 {
512- newSessionKey = null ;
514+ createSessionResponse . SetException ( new Exception ( "Something went wrong. Please try again later." ) ) ;
513515 Debug . LogError ( ex . Message ) ;
514516 }
517+ } else {
518+ createSessionResponse . SetException ( new Exception ( "Something went wrong. Please try again later." ) ) ;
515519 }
516520 }
517521 ) ) ;
518- await Task . Delay ( 200 ) ;
519- return newSessionKey ;
522+ return await createSessionResponse . Task ;
520523 }
521524
522525 public string getPrivKey ( )
You can’t perform that action at this time.
0 commit comments