refactor(socket): decouple command handling and add message sending

- Move command handler to variable for better flexibility
- Add SendMsg function for sending messages through socket
- Fix missing return statements in command execution
- Improve error handling in monitor exception reporting
This commit is contained in:
2026-04-28 19:55:45 +08:00
parent 3a0b591d5e
commit 58a8efc17a
4 changed files with 67 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"Watchdog_Linux-systemd/command"
"Watchdog_Linux-systemd/postLog"
"Watchdog_Linux-systemd/socket"
"fmt"
@@ -44,6 +45,10 @@ func main() {
}
postLog.Info(fmt.Sprintf("%s %s (Build %d.%s) by %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.Developer))
// Set command handler
socket.CommandHandler = command.ExecuteCommand
// End of command handler
go func() {
err := socket.BootSocket(Type, listenAddr, listenPort)
if err != nil {