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()); } }