Skip to content

Commit

Permalink
final preparation for hackathon
Browse files Browse the repository at this point in the history
upcoming: FINAL final preparation (probably but I hope not haha)
  • Loading branch information
milkshakeiii committed Jan 21, 2015
1 parent 60bd82a commit 4f115c4
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 20 deletions.
7 changes: 7 additions & 0 deletions InternalScripts/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@ public static string GetCurrentLog()
string currentLog = File.ReadAllText (logPath);
return currentLog;
}

public static void BasicLog(string extraLog)
{
Debug.Log (extraLog);
File.AppendAllText (GetLogPath (), System.Environment.NewLine + "---EXTRA EXTRA READ ALL ABOUT IT ---" +
System.Environment.NewLine + extraLog + System.Environment.NewLine);
}
}
}
2 changes: 1 addition & 1 deletion InternalScripts/ProblemKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static private void GetProblemsFromSeed()

static public void ReplaceSeed(Message.Problem.ProblemGetResponse reply)
{
Debug.Log ("Replacing seed file.");
Logger.BasicLog ("Replacing seed file.");
MemoryStream stream = new MemoryStream ();
reply.WriteTo (stream);
byte[] replacementBytes = stream.ToArray();
Expand Down
6 changes: 4 additions & 2 deletions InternalScripts/SenseixSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static public ArrayList GetCurrentPlayerList()
ArrayList returnList = new ArrayList ();
if (currentPlayerList == null)
{
Debug.Log("no current Player list. maybe not connected.");
Debug.Log("No current Player list. Maybe not connected.");
return returnList;
}

Expand Down Expand Up @@ -61,10 +61,12 @@ static public Message.Player.Player GetCurrentPlayer()

static public bool GetSessionState()
{
//Debug.Log ("returning inSession: " + inSession);
return inSession;
}
static public void SetSessionState(bool state)
{
//UnityEngine.Debug.Log ("Session state set to: " + state);
inSession = state;
}

Expand Down Expand Up @@ -160,7 +162,7 @@ static public void RegisterAllPlayers()
}
if (Players.Count > 0) SetCurrentPlayer (Players [0] as Message.Player.Player);
else
UnityEngine.Debug.LogWarning("There are no players. Could be very bad.");
UnityEngine.Debug.Log("There are no players. Maybe never connected.");
}

static public void PullLeaderboard(uint pageNumber, uint pageSize)
Expand Down
5 changes: 4 additions & 1 deletion MenuScripts/ConnectionIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ void Start () {

// Update is called once per frame
void Update () {
warningText.SetActive (!Senseix.SenseixSession.GetSessionState ());
bool indicateOffline = !Senseix.SenseixSession.GetSessionState ();
//if (indicateOffline)
// Debug.Log ("Showing offline indicator");
warningText.SetActive (indicateOffline);
}
}
}
10 changes: 6 additions & 4 deletions Messaging/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Request : MonoBehaviour
//API URLS
//api-staging.Senseix.com
const string ENCRYPTED = "http://";
const string SERVER_URL = "192.168.1.8:3000/";
const string SERVER_URL = "api.thinksylearn.com/";
const string API_VERSION = "v1";
const string GENERIC_HDR = ENCRYPTED + SERVER_URL + API_VERSION;
const string PARENT_HDR = GENERIC_HDR + "/devices/";
Expand Down Expand Up @@ -358,10 +358,12 @@ static public void PostProblems (string PlayerId, Queue problems)
queueParameters.responseHandler = Response.ParsePostProblemResponse;
queueParameters.url = POST_PROBLEM_URL;
WriteRequestToCache(queueParameters);
//UnityEngine.Debug.Log("Cache post");
}
else
{
NonblockingPostRequest (requestMessageStream, Response.ParsePostProblemResponse, POST_PROBLEM_URL, false);
//UnityEngine.Debug.Log("Post post");
}
}

Expand Down Expand Up @@ -443,15 +445,15 @@ static public void SubmitProblemPostCache()
string[] fileNames = Directory.GetFiles (directoryPath);
foreach (string fileName in fileNames)
{
UnityEngine.Debug.Log("Submitting cache");
//UnityEngine.Debug.Log("Submitting cache");
byte[] bytes = System.IO.File.ReadAllBytes(fileName);
Problem.ProblemPostRequest.Builder problemPostRequest = Problem.ProblemPostRequest.ParseFrom(bytes).ToBuilder();
for (int i = 0; i < problemPostRequest.ProblemCount; i++)
{
Problem.ProblemPost.Builder problemPostBuilder = problemPostRequest.GetProblem(i).ToBuilder();
SetPlayerForProblemIfNeeded(ref problemPostBuilder);
problemPostRequest.SetProblem(i, problemPostBuilder);
UnityEngine.Debug.Log(problemPostBuilder.PlayerId);
//UnityEngine.Debug.Log(problemPostBuilder.PlayerId);
}

MemoryStream requestMessageStream = new MemoryStream();
Expand Down Expand Up @@ -482,7 +484,7 @@ static private void SetPlayerForProblemIfNeeded(ref Senseix.Message.Problem.Prob
}
if (problemPostBuilder.PlayerId == "no current player")
{
UnityEngine.Debug.LogWarning("I'm sending a problem to the server with no player ID.");
//UnityEngine.Debug.LogWarning("I'm sending a problem to the server with no player ID.");
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions Messaging/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ static public bool ParseRegisterDeviceResponse(byte[] responseBytes)
//Debug.Log("save auth token.");
SenseixSession.SetAndSaveAuthToken(registerDeviceResponse.AuthToken);
SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("Temporary account: " + registerDeviceResponse.IsTemporaryAccount);
Logger.BasicLog("Temporary account: " + registerDeviceResponse.IsTemporaryAccount);
SenseixSession.SetSignedIn(!registerDeviceResponse.IsTemporaryAccount);
}
else
{
SenseixSession.SetSessionState(false);
UnityEngine.Debug.Log("Can't find key from result");
UnityEngine.Debug.LogWarning("Uninitialized register device response");
return false;
}
return true;
Expand All @@ -130,7 +130,7 @@ static public bool ParseListPlayerResponse(byte[] responseBytes)
Player.PlayerListResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a list Player Message");
Logger.BasicLog("I got a response from a list Player Message");
if (listPlayersResponse.PlayerCount == 0)
throw new Exception ("no players in player list");
SenseixSession.SetCurrentPlayerList(listPlayersResponse);
Expand All @@ -143,7 +143,7 @@ static public bool ParseRegisterPlayerResponse(byte[] responseBytes)
Player.PlayerRegisterWithApplicationResponse registerPlayerResponse =
Player.PlayerRegisterWithApplicationResponse.ParseFrom (responseBytes);
SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a register Player Message");
Logger.BasicLog("I got a response from a register Player Message");

return true;
}
Expand All @@ -155,7 +155,7 @@ static public bool ParseGetProblemResponse(byte[] responseBytes)
//Debug.Log("message length: " + reply.Message.Length);
//Debug.Log("has problem get: " + reply.HasProblemGet);
if (getProblemResponse.ProblemCount != ProblemKeeper.PROBLEMS_PER_PULL)
UnityEngine.Debug.LogWarning("How wude. I asked for " + ProblemKeeper.PROBLEMS_PER_PULL + " problems, but I only got " + getProblemResponse.ProblemCount);
Logger.BasicLog("How wude. I asked for " + ProblemKeeper.PROBLEMS_PER_PULL + " problems, but I only got " + getProblemResponse.ProblemCount);
if (getProblemResponse.ProblemCount == 0)
{
throw new Exception ("no problems in problem response.");
Expand All @@ -173,7 +173,7 @@ static public bool ParsePostProblemResponse(byte[] responseBytes)
Problem.ProblemPostResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a Problem post Message");
Logger.BasicLog("I got a response from a Problem post Message");
return true;
}

Expand All @@ -183,7 +183,7 @@ static public bool ParseVerifyGameResponse(byte[] responseBytes)
Device.GameVerificationResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from my game verification Message");
Logger.BasicLog("I got a response from my game verification Message");
return true;
}

Expand All @@ -193,7 +193,7 @@ static public bool ParseReportBugResponse(byte[] responseBytes)
Debug.DebugLogSubmitResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a debug log submit message.");
Logger.BasicLog("I got a response from a debug log submit message.");
return true;
}

Expand All @@ -204,7 +204,7 @@ static public bool ParsePlayerScoreResponse(byte[] responseBytes)
Leaderboard.UpdatePlayerScoreResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a Player score Message");
Logger.BasicLog("I got a response from a Player score Message");
return true;
}

Expand All @@ -214,7 +214,7 @@ static public bool ParsePlayerRankResponse(byte[] responseBytes)
Leaderboard.PlayerRankResponse.ParseFrom (responseBytes);

SenseixSession.SetSessionState(true);
UnityEngine.Debug.Log("I got a response from a Player rank Message");
Logger.BasicLog("I got a response from a Player rank Message");
return true;
}

Expand Down
Binary file modified Prefabs/SenseiX.prefab
Binary file not shown.
Binary file modified SenseiX.unitypackage
Binary file not shown.
5 changes: 3 additions & 2 deletions SenseixPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class SenseixPlugin : MonoBehaviour
private static SenseixPlugin singletonInstance;
private static Problem mostRecentProblem;

private const int reconnectRetryInterval = 9000;
private const int encouragementGetInterval = 9001;
private const int reconnectRetryInterval = 3000;
private const int encouragementGetInterval = 3001;

/// <summary>
/// Shows a window indicating that something horrible has happened.
Expand Down Expand Up @@ -53,6 +53,7 @@ void Awake()
singletonInstance = this;
Senseix.ProblemKeeper.CopyFailsafeOver ();
if (!offlineMode) Senseix.SenseixSession.InitializeSenseix (gameAccessToken);
NextProblem ();
}

void Update()
Expand Down

0 comments on commit 4f115c4

Please sign in to comment.