@@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
25
using UnityEngine ;
26
26
using System ;
27
27
using System . Text ;
28
+ using System . Threading . Tasks ;
28
29
#if WINDOWS_UWP
29
30
using Windows . Security . Cryptography ;
30
31
using Windows . Security . Cryptography . Core ;
@@ -109,41 +110,37 @@ private void HandleLogoutResult(MethodCall logoutCall) {
109
110
}
110
111
}
111
112
112
- public IEnumerator CreateUserAndLogin ( string username , string password ) {
113
+ public async Task CreateUserAndLogin ( string username , string password ) {
113
114
JSONObject loginPasswordObj = JSONObject . Create ( ) ;
114
115
loginPasswordObj . AddField ( "username" , username ) ;
115
116
loginPasswordObj . AddField ( "password" , GetPasswordObj ( password ) ) ;
116
117
117
- MethodCall loginCall = connection . Call ( "createUser" , loginPasswordObj ) ;
118
- yield return loginCall . WaitForResult ( ) ;
119
- HandleLoginResult ( loginCall ) ;
118
+ MethodCall loginCall = await connection . CallAsync ( "createUser" , loginPasswordObj ) ;
119
+ loginCall . OnResult += HandleLoginResult ;
120
120
}
121
121
122
- public IEnumerator Login ( string username , string password ) {
122
+ public async Task Login ( string username , string password ) {
123
123
JSONObject userObj = JSONObject . Create ( ) ;
124
124
userObj . AddField ( "username" , username ) ;
125
125
126
126
JSONObject loginPasswordObj = JSONObject . Create ( ) ;
127
127
loginPasswordObj . AddField ( "user" , userObj ) ;
128
128
loginPasswordObj . AddField ( "password" , GetPasswordObj ( password ) ) ;
129
129
130
- MethodCall loginCall = connection . Call ( "login" , loginPasswordObj ) ;
131
- yield return loginCall . WaitForResult ( ) ;
132
- HandleLoginResult ( loginCall ) ;
130
+ MethodCall loginCall = await connection . CallAsync ( "login" , loginPasswordObj ) ;
131
+ loginCall . OnResult += HandleLoginResult ;
133
132
}
134
133
135
- public IEnumerator ResumeSession ( string token ) {
134
+ public async Task ResumeSession ( string token ) {
136
135
JSONObject tokenObj = JSONObject . Create ( ) ;
137
136
tokenObj . AddField ( "resume" , token ) ;
138
137
139
- MethodCall loginCall = connection . Call ( "login" , tokenObj ) ;
140
- yield return loginCall . WaitForResult ( ) ;
141
- HandleLoginResult ( loginCall ) ;
138
+ MethodCall loginCall = await connection . CallAsync ( "login" , tokenObj ) ;
139
+ loginCall . OnResult += HandleLoginResult ;
142
140
}
143
141
144
- public IEnumerator Logout ( ) {
145
- MethodCall logoutCall = connection . Call ( "logout" ) ;
146
- yield return logoutCall . WaitForResult ( ) ;
142
+ public async Task Logout ( ) {
143
+ MethodCall logoutCall = await connection . CallAsync ( "logout" ) ;
147
144
HandleLogoutResult ( logoutCall ) ;
148
145
}
149
146
0 commit comments