Skip to content
Snippets Groups Projects

Web socket server

Merged Marcel Kehrberg requested to merge WebSocketServer into develop
1 file
+ 28
1
Compare changes
  • Side-by-side
  • Inline
@@ -267,7 +267,34 @@ namespace InnoLabProjektDektopApp
@@ -267,7 +267,34 @@ namespace InnoLabProjektDektopApp
// Ereignis-Handler für den "Start"-Button
// Ereignis-Handler für den "Start"-Button
private void StartButton_Click(object sender, RoutedEventArgs e)
private void StartButton_Click(object sender, RoutedEventArgs e)
{
{
Server.Instance.SendMessageToAllClients("true");
Server.Instance.SendMessageToAllClients("{\"action\": \"startTracking\", \"status\": true}");
 
 
try
 
{
 
string jsonContent = File.ReadAllText("F:\\Dokumente\\Schule\\Studium\\InoLab\\procrastinator\\InnoLabProjektDektopApp\\InnoLabProjektDektopApp\\Assets\\distractingWebsites.json");
 
//string message = $"{{\"action\": \"sendJsonContent\", \"status\": true, \"content\": {jsonContent}}}";
 
 
// Erstelle ein Objekt für die Nachricht
 
var messageObject = new
 
{
 
action = "sendJsonContent",
 
status = true,
 
content = JsonSerializer.Deserialize<object>(jsonContent) // Parse den JSON-Inhalt
 
};
 
 
// Serialisiere das Objekt zu einem JSON-String
 
string message = JsonSerializer.Serialize(messageObject);
 
 
Server.Instance.SendMessageToAllClients(message);
 
}
 
catch
 
{
 
 
}
 
 
 
 
// Werte auslesen
// Werte auslesen
int focusPeriod;
int focusPeriod;
Loading