This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Startup.cs
77 lines (68 loc) · 2.19 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using UnityEngine;
using System.Collections;
using Services;
using Services.User;
public class Startup : MonoBehaviour {
// Use this for initialization
void Start () {
using (ThriftClient clientService = new ThriftClient("User.v1"))
{
User.Client client = (User.Client)clientService.GetClient();
UserModel user = null;
string username = "foo";
string password = "bar";
bool success = client.login(username, password);
if (success)
{
Debug.Log("Login Success!");
}
else
{
Debug.Log("Login failed!");
Debug.Log("Trying to create user");
// try to create and login
user = client.create(username, password);
if (user.User_id != 0) {
Debug.Log("Created user!");
Debug.Log(user.ToString());
Debug.Log("Trying a login now.");
success = client.login(user.Username, user.Password);
if (success)
{
Debug.Log("Login succeeded!");
}
else
{
Debug.Log("login failed!");
}
}
else
{
Debug.Log("User creation failed!");
}
}
user = client.get(username);
if (user.User_id != 0)
{
Debug.Log("Got user from client:");
Debug.Log(user.ToString());
bool removed = client.remove(user.User_id);
if (removed)
{
Debug.Log("Successfully removed user with id: " + user.User_id);
}
else
{
Debug.Log("Failed to remove user!");
}
}
else
{
Debug.Log("Failed to get user with username: " + username);
}
}
}
// Update is called once per frame
void Update () {
}
}