feat: introduce vars.go for websocket package

- update comments
- move `Done` variable to vars.go
- move `Connected()` method

🤖
This commit is contained in:
Sebastian Mark 2024-11-21 12:25:45 +01:00
parent 342ecde6bb
commit 9b7dc19935
3 changed files with 10 additions and 7 deletions

View file

@ -8,7 +8,8 @@ import (
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
)
type Client ChronoTomato.GoTomatoClient // New websocket client
// New websocket client
type Client ChronoTomato.GoTomatoClient
// Connects to websocket
func Connect(url string) Client {
@ -17,10 +18,6 @@ func Connect(url string) Client {
return Client{Conn: conn, Server: url, LastErr: err}
}
func (c Client) Connected() bool {
return c.Conn != nil
}
// Disconnects from websocket
func (c Client) Disconnect() {
// Cleanly close the connection by sending a close message and then
@ -34,3 +31,7 @@ func (c Client) Disconnect() {
}
return
}
func (c Client) Connected() bool {
return c.Conn != nil
}