Skip to content

Commit 581fa83

Browse files
committed
basic calls working
1 parent 0773390 commit 581fa83

1 file changed

Lines changed: 50 additions & 47 deletions

File tree

Allow2/Allow2.cs

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010

1111
using Application;
12+
using System.Collections;
1213
using UnityEngine;
1314
using UnityEngine.Networking;
1415

@@ -21,7 +22,7 @@ namespace Allow2
2122
public static class Allow2
2223
{
2324

24-
public static string deviceToken = "Not Set";
25+
public static string deviceToken = "Not Set"; // ie: "346-34269hcubi-187gigi8g-14i3ugkug",
2526
public static EnvType env = EnvType.Production;
2627

2728
//
@@ -62,56 +63,58 @@ public static string serviceUrl
6263
}
6364
}
6465

65-
//public static void Pair(string user, // ie: "fred@gmail.com",
66-
// string pass, // ie: "my super secret password",
67-
// string deviceToken, // ie: "346-34269hcubi-187gigi8g-14i3ugkug",
68-
// string deviceName // ie: "Fred's iPhone"
69-
// ) {
70-
// WWWForm form = new WWWForm();
71-
// form.AddField("user", user);
72-
// form.AddField("pass", pass);
73-
// form.AddField("deviceToken", deviceToken);
74-
// form.AddField("name", deviceName);
66+
public static IEnumerator Pair(string user, // ie: "fred@gmail.com",
67+
string pass, // ie: "my super secret password",
68+
string deviceName // ie: "Fred's iPhone"
69+
) {
70+
WWWForm form = new WWWForm();
71+
form.AddField("user", user);
72+
form.AddField("pass", pass);
73+
form.AddField("deviceToken", deviceToken);
74+
form.AddField("name", deviceName);
75+
76+
Debug.Log(apiUrl + "/api/pairDevice");
77+
Debug.Log(form);
7578

76-
// using (UnityWebRequest www = UnityWebRequest.Post(apiUrl + "/api/pairDevice", form))
77-
// {
78-
// yield return www.SendWebRequest();
79+
using (UnityWebRequest www = UnityWebRequest.Post(apiUrl + "/api/pairDevice", form))
80+
{
81+
yield return www.SendWebRequest();
7982

80-
// if (www.isNetworkError || www.isHttpError)
81-
// {
82-
// Debug.Log(www.error);
83-
// }
84-
// else
85-
// {
86-
// Debug.Log(www.downloadHandler.text);
87-
// }
88-
// }
89-
//}
83+
if (www.isNetworkError || www.isHttpError)
84+
{
85+
Debug.Log(www.error);
86+
}
87+
else
88+
{
89+
Debug.Log(www.downloadHandler.text);
90+
}
91+
}
92+
}
9093

91-
//public static void Check(int userId,
92-
// string pairToken, // ie: "98hbieg87-ilulieugil-dilufkucy"
93-
// string deviceToken, // ie: "iug893-kjg-fiug23"
94-
// string timezone, // ie: "Australia/Brisbane"
95-
// int childId,
96-
// int[] activities,
97-
// bool log = false,
98-
// bool staging = false // INTERNAL USE ONLY!
99-
// ) {
100-
// UnityWebRequest www = UnityWebRequest.Get("http://www.my-server.com");
101-
// yield return www.SendWebRequest();
94+
public static IEnumerator Check(int userId,
95+
string pairToken, // ie: "98hbieg87-ilulieugil-dilufkucy"
96+
string deviceToken, // ie: "iug893-kjg-fiug23"
97+
string timezone, // ie: "Australia/Brisbane"
98+
int childId,
99+
int[] activities,
100+
bool log = false,
101+
bool staging = false // INTERNAL USE ONLY!
102+
) {
103+
UnityWebRequest www = UnityWebRequest.Get("http://www.my-server.com");
104+
yield return www.SendWebRequest();
102105

103-
// if (www.isNetworkError || www.isHttpError)
104-
// {
105-
// Debug.Log(www.error);
106-
// }
107-
// else
108-
// {
109-
// // Show results as text
110-
// Debug.Log(www.downloadHandler.text);
106+
if (www.isNetworkError || www.isHttpError)
107+
{
108+
Debug.Log(www.error);
109+
}
110+
else
111+
{
112+
// Show results as text
113+
Debug.Log(www.downloadHandler.text);
111114

112-
// // Or retrieve results as binary data
113-
// byte[] results = www.downloadHandler.data;
114-
// }
115-
//}
115+
// Or retrieve results as binary data
116+
byte[] results = www.downloadHandler.data;
117+
}
118+
}
116119
}
117120
}

0 commit comments

Comments
 (0)