doc: add and improve comments

This commit is contained in:
Sebastian Mark 2024-10-30 11:03:18 +01:00
parent 6187122b81
commit f19ab81dc8
11 changed files with 31 additions and 8 deletions

View file

@ -10,6 +10,7 @@ import (
type Client ChronoTomato.GoTomatoClient // New websocket client
// Connects to websocket
func Connect(url string) Client {
log.Info("Connected 󰖟 ", "host", url)
@ -21,6 +22,7 @@ func Connect(url string) Client {
return Client{Conn: conn}
}
// Disconnects from websocket
func (c Client) Disconnect() {
select {
case <-Done:

View file

@ -11,6 +11,7 @@ import (
var Done = make(chan struct{})
// Receives websocket messages and write them to `channel`
func (c Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
var serverMessage GoTomato.ServerMessage

View file

@ -8,6 +8,7 @@ import (
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
)
// Sends to ClientCommand to the clients websocket
func (c Client) sendClientCommand(msg GoTomato.ClientCommand) {
messageBytes, err := json.Marshal(msg)
if err != nil {
@ -22,6 +23,7 @@ func (c Client) sendClientCommand(msg GoTomato.ClientCommand) {
}
}
// Sends the passed command to the server
func (c Client) SendCmd(cmd string) {
message := GoTomato.ClientCommand{
Command: cmd,
@ -31,6 +33,7 @@ func (c Client) SendCmd(cmd string) {
c.sendClientCommand(message)
}
// Sends the new PomodoroConfig to the server
func (c Client) SendSettingsUpdate(settings GoTomato.PomodoroConfig) {
message := GoTomato.ClientCommand{
Command: "updateSettings",