Skip to content

Commit

Permalink
chore: Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Mar 12, 2024
1 parent 3844bcf commit 749aca9
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,9 @@ import (
)

const (
// Time allowed to write a message to the peer.
writeWait = 10 * time.Second

// Maximum message size allowed from peer.
maxMessageSize = 1 * 1024 * 1024 // bytes
)

var (
newline = []byte{'\n'}
notFoundMsg = []byte(`{"e":"not_found"}`)
disconnectMsg = []byte(`{"data": {"":{"@system":{"client_disconnect":true}}}}`)
clearStateMsg = []byte(`{"c":1}`)
writeWait = 10 * time.Second // Time allowed to write a message to the peer.
maxMessageSize = 1 * 1024 * 1024 // bytes Maximum message size allowed from peer.
// TODO: Refactor into iota.
STATE_CREATED = "CREATED"
STATE_TIMEOUT = "TIMEOUT"
STATE_LISTEN = "LISTEN"
Expand All @@ -46,6 +37,13 @@ var (
STATE_CLOSED = "CLOSED"
)

var (
newline = []byte{'\n'}
notFoundMsg = []byte(`{"e":"not_found"}`)
disconnectMsg = []byte(`{"data": {"":{"@system":{"client_disconnect":true}}}}`)
clearStateMsg = []byte(`{"c":1}`)
)

// BootMsg represents the initial message sent to an app when a client first connects to it.
type BootMsg struct {
Data struct {
Expand Down Expand Up @@ -131,7 +129,7 @@ func (c *Client) listen() {
}
}

echo(Log{"t": "client_unsubscribe", "client": c.id, "state": c.state})
echo(Log{"t": "client_unsubscribe", "client": c.id})
c.broker.unsubscribe <- c
c.state = STATE_CLOSED
return
Expand Down

0 comments on commit 749aca9

Please sign in to comment.