[chronojump/networks] Changes for Chronojump Networks: * Don't send station_id, is not used, the authentication token alre
- From: Leninux <leningols src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/networks] Changes for Chronojump Networks: * Don't send station_id, is not used, the authentication token alre
- Date: Fri, 4 Jun 2021 19:11:51 +0000 (UTC)
commit 839963cd93331addc6f85ba90fc23b04586985dc
Author: Leninux <arnau lenin sobtec cat>
Date: Fri Jun 4 21:09:30 2021 +0200
Changes for Chronojump Networks:
* Don't send station_id, is not used, the authentication token already has this information
* Send player_id instead of person_id
* Remove Data suffix from endpoints
* GetStationExercises is no longer a POST request, use GET instead.
src/gui/networks.cs | 4 ++--
src/json/compujump.cs | 50 +++++++++++++++-----------------------------------
2 files changed, 17 insertions(+), 37 deletions(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 33017e1b8..0060c42cd 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -939,7 +939,7 @@ public partial class ChronoJumpWindow
{
//1) get tasks
JsonCompujump json = new JsonCompujump(configChronojump.CompujumpDjango);
- List<Task> tasks = json.GetTasks(currentPerson.UniqueID, configChronojump.CompujumpStationID);
+ List<Task> tasks = json.GetTasks(currentPerson.UniqueID);
//2) get exercises and insert if needed (only on encoder)
if(configChronojump.CompujumpStationMode == Constants.Menuitem_modes.POWERGRAVITATORY ||
@@ -950,7 +950,7 @@ public partial class ChronoJumpWindow
type = Constants.EncoderGI.INERTIAL;
ArrayList encoderExercisesOnLocal = SqliteEncoder.SelectEncoderExercises(false, -1,
false, type);
- List<EncoderExercise> exRemote_list =
json.GetStationExercises(configChronojump.CompujumpStationID, type);
+ List<EncoderExercise> exRemote_list = json.GetStationExercises(type);
foreach(EncoderExercise exRemote in exRemote_list)
{
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 06054be9d..9a311d61a 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -47,7 +47,7 @@ public class JsonCompujump : Json
Person person = new Person(-1);
// Create a request using a URL that can receive a post.
- if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getPersonByRFID"))
+ if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getPlayerByRFID"))
return person;
// Set the Method property of the request to POST.
@@ -162,7 +162,7 @@ public class JsonCompujump : Json
return true;
}
- public List<Task> GetTasks(int personID, int stationID)
+ public List<Task> GetTasks(int personID)
{
connected = false;
@@ -175,9 +175,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
-
- json.Add("person_id", personID.ToString());
- json.Add("station_id", stationID.ToString());
+ json.Add("player_id", personID.ToString());
// Converts it to a String
String js = json.ToString();
@@ -286,7 +284,7 @@ public class JsonCompujump : Json
}
//get pending tasks on other stations
- public List<StationCount> GetOtherStationsWithPendingTasks(int personID, int stationID)
+ public List<StationCount> GetOtherStationsWithPendingTasks(int personID)
{
// Create a request using a URL that can receive a post.
if (! createWebRequest(requestType.AUTHENTICATED,
"/api/v1/client/getOtherStationsWithPendingTasks"))
@@ -297,8 +295,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
- json.Add("person_id", personID.ToString());
- json.Add("station_id", stationID.ToString());
+ json.Add("player_id", personID.ToString());
// Converts it to a String
String js = json.ToString();
@@ -343,7 +340,7 @@ public class JsonCompujump : Json
}
//stationType can be GRAVITATORY or INERTIAL
- public List<EncoderExercise> GetStationExercises(int stationId, Constants.EncoderGI stationType)
+ public List<EncoderExercise> GetStationExercises(Constants.EncoderGI stationType)
{
List<EncoderExercise> ex_list = new List<EncoderExercise>();
@@ -351,24 +348,8 @@ public class JsonCompujump : Json
if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/getStationExercises"))
return ex_list;
- // Set the Method property of the request to POST.
- request.Method = "POST";
-
- // Creates the json object
- JsonObject json = new JsonObject();
- json.Add("station_id", stationId);
-
- // Converts it to a String
- String js = json.ToString();
-
- // Writes the json object into the request dataStream
- Stream dataStream;
- if(! getWebRequestStream (request, out dataStream, Catalog.GetString("Could not get station
exercises.")))
- return ex_list;
-
- dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
- dataStream.Close ();
+ // Set the Method property of the request to GET.
+ request.Method = "GET";
HttpWebResponse response;
if(! getHttpWebResponse (request, out response, Catalog.GetString("Could not get station
exercises.")))
@@ -393,6 +374,7 @@ public class JsonCompujump : Json
return ex_list;
}
+
private List<EncoderExercise> stationExercisesDeserialize(string str, Constants.EncoderGI stationType)
{
List<EncoderExercise> ex_list = new List<EncoderExercise>();
@@ -497,7 +479,7 @@ public class JsonCompujump : Json
{
LogB.Information("calling upload sprint");
// Create a request using a URL that can receive a post.
- if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadSprintData"))
+ if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadSprint"))
return false;
/*
@@ -511,7 +493,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
- json.Add("person_id", o.personId);
+ json.Add("player_id", o.personId);
json.Add("distances", o.sprintPositions);
json.Add("t1", o.splitTimesL[1]);
@@ -586,7 +568,7 @@ public class JsonCompujump : Json
public bool UploadEncoderData(UploadEncoderDataFullObject o)
{
// Create a request using a URL that can receive a post.
- if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadEncoderData"))
+ if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadEncoder"))
return false;
// Set the Method property of the request to POST.
@@ -594,8 +576,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
- json.Add("person_id", o.personId);
- json.Add("station_id", o.stationId);
+ json.Add("player_id", o.personId);
//json.Add("exercise_name", Util.RemoveAccents(exerciseName));
json.Add("exercise_id", o.exerciseId);
json.Add("laterality", o.laterality);
@@ -650,7 +631,7 @@ public class JsonCompujump : Json
public bool UploadForceSensorData(UploadForceSensorDataFullObject o)
{
// Create a request using a URL that can receive a post.
- if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadForceSensorData"))
+ if (! createWebRequest(requestType.AUTHENTICATED, "/api/v1/client/uploadForceSensor"))
return false;
// Set the Method property of the request to POST.
@@ -658,8 +639,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
- json.Add("person_id", o.personId);
- json.Add("station_id", o.stationId);
+ json.Add("player_id", o.personId);
//json.Add("exercise_name", Util.RemoveAccents(exerciseName));
json.Add("exercise_id", o.exerciseId);
json.Add("laterality", o.laterality);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]