mirror of
https://git.battle-of-pip.de/root/vpr-mitarbeiterverwaltung.git
synced 2025-10-14 10:04:52 +02:00
Fehlerbehebung von TCP-Eingangsnachrichten beim Server (DX86.cs)
Implementierung CommandManager.cs in BackendServer.cs Worker.cs umbennannt zu Employee.cs WorkerState.cs umbenannt zu EmployeeState.cs .help command eingefügt (HelpCommand.cs) Management-Server auf port 3767 eingefügt (Program.cs) Server-Connector (Server.cs) erste methoden eingefügt GetEmployee Login Logout clockin,clockout,clockbreak
This commit is contained in:
@@ -5,11 +5,11 @@ namespace Server;
|
||||
|
||||
public class BackendServer : DX86.TcpServer
|
||||
{
|
||||
CommandManager _CommandManager;
|
||||
CommandManager commandManager;
|
||||
public BackendServer(string address, int port, MessageSender ms) : base(address, port, ms)
|
||||
{
|
||||
ms.Log("[BACKENDSERVER] Setting up server.");
|
||||
_CommandManager = new CommandManager();
|
||||
commandManager = new CommandManager();
|
||||
ms.Log("[BACKENDSERVER] Server Setup Complete.");
|
||||
}
|
||||
|
||||
@@ -49,6 +49,6 @@ public class BackendServer : DX86.TcpServer
|
||||
string command = args[0].Substring(1); // Remove the leading dot
|
||||
string[] commandArgs = args.Skip(1).ToArray(); // Get the arguments after the command
|
||||
|
||||
|
||||
commandManager.ExecuteCommand(executor:command, args:commandArgs, client:client, clientSocket:this);
|
||||
}
|
||||
}
|
@@ -1,4 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using DX86;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Server;
|
||||
@@ -30,11 +32,11 @@ public class CommandManager
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteCommand(string executor, params string[] args)
|
||||
public void ExecuteCommand(string executor, TcpClient? client = null, TcpServer? clientSocket = null, params string[] args)
|
||||
{
|
||||
if (_commands.TryGetValue(executor, out var command))
|
||||
{
|
||||
command.Exec(args);
|
||||
command.Exec(args:args, client:client, clientSocket:clientSocket);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
24
Server/Commands/HelpCommand.cs
Normal file
24
Server/Commands/HelpCommand.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Net.Sockets;
|
||||
using DX86;
|
||||
|
||||
namespace Server.Commands;
|
||||
|
||||
public class HelpCommand : ICommand
|
||||
{
|
||||
public string Executor { get; }
|
||||
public HelpCommand()
|
||||
{
|
||||
Executor = "help";
|
||||
}
|
||||
public void Exec(string[] args, TcpClient? client = null, TcpServer? clientSocket = null)
|
||||
{
|
||||
clientSocket.SendMessageAsync(client, "" +
|
||||
"Available commands:\n" +
|
||||
"1. help - Show this help message\n" +
|
||||
"2. exit - Exit the server\n" +
|
||||
"3. user - User management\n" +
|
||||
"4. settings - Server settings\n" +
|
||||
"5. start - Start the server\n" +
|
||||
"6. stop - Stop the server\n");
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using DX86.Modules;
|
||||
using DX86;
|
||||
using DX86.Modules;
|
||||
using Library;
|
||||
|
||||
namespace Server;
|
||||
@@ -10,6 +11,7 @@ class Program
|
||||
public static InputBox inputBox;
|
||||
public static ItemSelector itemSelector;
|
||||
public static MySQL mySql;
|
||||
private static List<TcpServer> servers;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
@@ -19,16 +21,28 @@ class Program
|
||||
messageBox = new MessageBox(messageSender);
|
||||
inputBox = new InputBox(messageSender);
|
||||
itemSelector = new ItemSelector(messageSender);
|
||||
servers = new List<TcpServer>();
|
||||
|
||||
// Connect to the database
|
||||
//mySql = new MySQL("username", "password", "localhost", "database", messageSender);
|
||||
|
||||
// Start the server
|
||||
|
||||
messageBox.ShowAsync("Server started", ["LOL","Laurenz Stinkt xd"]);
|
||||
string name = inputBox.ShowAsync("Test", ["type your name "]);
|
||||
ServerLoop();
|
||||
|
||||
messageBox.ShowAsync("Welcome", ["Hello " + name]);
|
||||
|
||||
}
|
||||
|
||||
private static void ServerLoop()
|
||||
{
|
||||
bool running = true;
|
||||
string[] menuItems;
|
||||
string selectedItem;
|
||||
servers.Add(new BackendServer("0.0.0.0", 3767, messageSender));
|
||||
// Main server loop
|
||||
while (running)
|
||||
{
|
||||
menuItems = [ "Benutzerverwaltung", "Einstellungen", "Beenden" ];
|
||||
itemSelector.SetTitle("Hauptmenü");
|
||||
//selectedItem = itemSelector.SelectItemFromList(menuItems);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user