mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
refactor: move some of client network logic into mainscreen
This commit is contained in:
@@ -22,12 +22,14 @@ import (
|
||||
"strings"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/illusionman1212/gorc/client"
|
||||
"github.com/illusionman1212/gorc/parser"
|
||||
)
|
||||
|
||||
type State struct {
|
||||
content string
|
||||
Reader *bufio.Reader
|
||||
Client *client.Client
|
||||
}
|
||||
|
||||
func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
@@ -39,6 +41,13 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
fullMsg := fmt.Sprintf("%s %s %s", message.Source, message.Command, strings.Join(message.Parameters, " "))
|
||||
s.content += fullMsg
|
||||
|
||||
// TODO: handle different commands
|
||||
switch message.Command {
|
||||
case "PING":
|
||||
s.Client.SendCommand("PONG")
|
||||
break
|
||||
}
|
||||
|
||||
return s, s.readFromServer
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user