Now ctui reads messages from server. Yay!
This commit is contained in:
parent
b51ebb0560
commit
0ef750ca97
|
@ -81,6 +81,7 @@ func FE_ConnectTLS(t *TUI, data dataT) error {
|
||||||
}
|
}
|
||||||
t.stateChannel <- "TLS Connected"
|
t.stateChannel <- "TLS Connected"
|
||||||
t.isConnected = true
|
t.isConnected = true
|
||||||
|
go t.launchReadingMessagesFromConnection()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
package tui
|
|
26
tui/reading.go
Normal file
26
tui/reading.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package tui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"git.qowevisa.me/Qowevisa/gotell/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NOTE: should be launched as goroutine
|
||||||
|
func (t *TUI) launchReadingMessagesFromConnection() {
|
||||||
|
if t.messageChannel == nil {
|
||||||
|
t.errors <- errors.WrapErr("t.messageChannel", errors.NOT_INIT)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
buf := make([]byte, CONST_MESSAGE_LEN)
|
||||||
|
for {
|
||||||
|
n, err := t.tlsConnection.Read(buf)
|
||||||
|
if err != nil {
|
||||||
|
if err != io.EOF {
|
||||||
|
t.errors <- errors.WrapErr("t.tlsConnection.Read", err)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
t.messageChannel <- buf[:n]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user