up
This commit is contained in:
@@ -6,13 +6,14 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "git.rouggy.com/rouggy/ShackMaster/internal/devices"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
host string
|
||||
port int
|
||||
idNumber int
|
||||
conn net.Conn
|
||||
host string
|
||||
port int
|
||||
conn net.Conn
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
@@ -31,11 +32,10 @@ type Status struct {
|
||||
Connected bool `json:"connected"`
|
||||
}
|
||||
|
||||
func New(host string, port int, idNumber int) *Client {
|
||||
func New(host string, port int) *Client {
|
||||
return &Client{
|
||||
host: host,
|
||||
port: port,
|
||||
idNumber: idNumber,
|
||||
host: host,
|
||||
port: port,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,11 @@ func (c *Client) sendCommand(cmd string) (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Format command with ID
|
||||
fullCmd := fmt.Sprintf("C%d|%s\n", c.idNumber, cmd)
|
||||
// Get next command ID from global counter
|
||||
cmdID := GetGlobalCommandID().GetNextID()
|
||||
|
||||
// Format command with ID: C<id>|<command>
|
||||
fullCmd := fmt.Sprintf("C%d|%s\n", cmdID, cmd)
|
||||
|
||||
// Send command
|
||||
_, err := c.conn.Write([]byte(fullCmd))
|
||||
|
||||
Reference in New Issue
Block a user