Skip to content

Commit

Permalink
adding start and end function
Browse files Browse the repository at this point in the history
  • Loading branch information
EarliestFall988 committed Dec 9, 2023
1 parent e5a854a commit fc6426a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
8 changes: 8 additions & 0 deletions State Machine/FunctionLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Security.Cryptography;
using System.Threading.Tasks;

using Valkyrie_Server.State_Machine.Function_Definitions;

using ValkyrieFSMCore.WM;

namespace ValkyrieFSMCore
Expand Down Expand Up @@ -76,6 +78,12 @@ public void BuildFunctionLibrary()
ImportedFunctions.Add(splitProject.Name, splitProject);

#endregion

var start = new StartFunction();
var end = new ExitFunction();

ImportedFunctions.Add(start.Name, start);
ImportedFunctions.Add(end.Name, end);
}

/// <summary>
Expand Down
38 changes: 23 additions & 15 deletions ValkyrieServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,37 @@ public ValkyrieServerController()
var functionJSON = GetSyncDataHandler.GetSyncData();
Debug.WriteLine(functionJSON);

using HttpClient client = new();
try
{

HttpContent content = new StringContent(functionJSON);
using HttpClient client = new();

client.DefaultRequestHeaders.Add("x-api-key", ValkyrieAPIKey);
client.DefaultRequestHeaders.Add("x-instruction-id", instructionId);
var response = await client.PostAsync(prodSyncFunctionsURITestBranch, content);
HttpContent content = new StringContent(functionJSON);

using StreamReader reader = new StreamReader(response.Content.ReadAsStream());
client.DefaultRequestHeaders.Add("x-api-key", ValkyrieAPIKey);
client.DefaultRequestHeaders.Add("x-instruction-id", instructionId);
var response = await client.PostAsync(prodSyncFunctionsURITestBranch, content);

string responseString = await reader.ReadToEndAsync();
using StreamReader reader = new StreamReader(response.Content.ReadAsStream());

if (!response.IsSuccessStatusCode)
{
return ("Server Response Error: " + response.StatusCode + "\n" + responseString, false, response.StatusCode.ToString());
}
string responseString = await reader.ReadToEndAsync();

if (string.IsNullOrEmpty(responseString))
if (!response.IsSuccessStatusCode)
{
return ("Server Response Error: " + response.StatusCode + "\n" + responseString, false, response.StatusCode.ToString());
}

if (string.IsNullOrEmpty(responseString))
{
return ("Error: Empty response from server", false, "0");
}

return (responseString, response.IsSuccessStatusCode, response.ReasonPhrase ?? "");
}
catch (Exception ex)
{
return ("Error: Empty response from server", false, "0");
return (ex.Message, false, "0");
}

return (responseString, response.IsSuccessStatusCode, response.ReasonPhrase ?? "");
}
}

Expand Down

0 comments on commit fc6426a

Please sign in to comment.