chore: tuic-server support heartbeat command
This commit is contained in:
parent
81e03ec904
commit
df306be1ec
2 changed files with 9 additions and 2 deletions
|
@ -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
|
c.CommandHead = head
|
||||||
if c.CommandHead.TYPE != HeartbeatType {
|
if c.CommandHead.TYPE != HeartbeatType {
|
||||||
err = fmt.Errorf("error command type: %s", c.CommandHead.TYPE)
|
err = fmt.Errorf("error command type: %s", c.CommandHead.TYPE)
|
||||||
|
@ -357,7 +357,7 @@ func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Response,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadHeartbeat(reader BufferedReader) (c Response, err error) {
|
func ReadHeartbeat(reader BufferedReader) (c Heartbeat, err error) {
|
||||||
head, err := ReadCommandHead(reader)
|
head, err := ReadCommandHead(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -261,6 +261,13 @@ func (s *serverHandler) handleUniStream() (err error) {
|
||||||
writeClosed := v.(*atomic.Bool)
|
writeClosed := v.(*atomic.Bool)
|
||||||
writeClosed.Store(true)
|
writeClosed.Store(true)
|
||||||
}
|
}
|
||||||
|
case HeartbeatType:
|
||||||
|
var heartbeat Heartbeat
|
||||||
|
heartbeat, err = ReadHeartbeatWithHead(commandHead, reader)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
heartbeat.BytesLen()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in a new issue