chore: tuic-server support heartbeat command

This commit is contained in:
wwqgtxx 2022-11-28 18:28:22 +08:00
parent 562819e3ca
commit 4b1d4a3e20
2 changed files with 9 additions and 2 deletions

View file

@ -349,7 +349,7 @@ func NewHeartbeat() Heartbeat {
}
}
func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Response, err error) {
func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Heartbeat, err error) {
c.CommandHead = head
if c.CommandHead.TYPE != HeartbeatType {
err = fmt.Errorf("error command type: %s", c.CommandHead.TYPE)
@ -357,7 +357,7 @@ func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Response,
return
}
func ReadHeartbeat(reader BufferedReader) (c Response, err error) {
func ReadHeartbeat(reader BufferedReader) (c Heartbeat, err error) {
head, err := ReadCommandHead(reader)
if err != nil {
return

View file

@ -261,6 +261,13 @@ func (s *serverHandler) handleUniStream() (err error) {
writeClosed := v.(*atomic.Bool)
writeClosed.Store(true)
}
case HeartbeatType:
var heartbeat Heartbeat
heartbeat, err = ReadHeartbeatWithHead(commandHead, reader)
if err != nil {
return
}
heartbeat.BytesLen()
}
return
}()