Some changes in tui

This commit is contained in:
qowevisa 2024-05-25 09:19:41 +03:00
parent 00781f23d2
commit 0aa796bb27
2 changed files with 9 additions and 9 deletions

View File

@ -13,25 +13,24 @@ func (t *TUI) launchMessageChannel() error {
}
go func() {
for message := range t.messageChannel {
t.createNotification(string(message), "Message!")
msg, err := communication.Decode(message)
t.errorsChannel <- err
if err != nil {
continue
}
switch msg.Type {
case communication.SERVER_COMMAND:
t.handleServerCommands(msg.Data)
switch msg.From {
case communication.FROM_SERVER:
t.handleServerCommands(*msg)
case communication.FROM_CLIENT:
t.createNotification(string(msg.Data), "Server Message!")
}
}
}()
return nil
}
func (t *TUI) handleServerCommands(data []byte) {
if len(data) == 1 {
if data[0] == communication.NICKNAME {
func (t *TUI) handleServerCommands(data communication.Message) {
if data.About == communication.ABOUT_NICKNAME {
t.SendMessageToServer("Nickname", 16)
}
}
}

View File

@ -24,4 +24,5 @@ func (t *TUI) SendMessageToServer(title string, minW int) {
if err != nil {
t.errorsChannel <- errors.WrapErr("t.drawSelectedWidget", err)
}
t.readInputState <- true
}