blob: f91ae34eec8792f1021f722263860476d1971df5 (
plain)
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
|
package shared;
import haxe.Http;
import haxe.Json;
import shared.Types.ScoreBoardData;
class ScoreBoard
{
var scoreBoardSecret:String = '8lykk7evgka9JqFzCs_C-QSBPeydJIUEa_vSuoSRJYJQ';
var scoreBoardPublicId:String = '6144ce1e8f40bb0e285c6d95';
var scoreBoardSetUrl:String;
var baseUrl:String = 'http://dreamlo.com';
public function new()
{
this.scoreBoardSetUrl = '$baseUrl/lb/$scoreBoardSecret/add';
}
public function setScore(name:String, guid:String, score:Int)
{
var scoreUrl:String = '$scoreBoardSetUrl/$guid/$score/0/$name';
var request:Http = new Http(scoreUrl);
trace(scoreUrl);
// request.onData = function(data)
// {
// trace(data);
// }
request.onError = function(error)
{
trace(error);
}
request.request(false);
}
public function getScores():ScoreBoardData
{
var scoresUrl:String = '$baseUrl/lb/$scoreBoardPublicId/json';
var request:Http = new Http(scoresUrl);
request.onData = function(data)
{
// trace(data);
}
request.onError = function(error)
{
trace(error);
}
request.request(false);
var response = request.responseBytes;
return Json.parse(response.toString());
}
}
|