spark-server/internal/transport/tcp/flush.go
2026-09-16 19:08:06 +08:00

26 lines
583 B
Go

package tcp
import (
"spark-server/internal/transport/tcp/protocol"
"spark-server/internal/transport/tcp/session"
)
func (s *Server) flush(st *connState) {
if st == nil || st.sess == nil {
return
}
for _, p := range st.sess.DrainOutbound(32) {
s.writeEncoded(st, packetFrame(p))
}
}
func packetFrame(p *session.Packet) protocol.Frame {
if p == nil {
return protocol.Frame{}
}
return protocol.Frame{
Magic: protocol.Magic, Version: protocol.CurrentVersion,
Command: p.Command, Flags: p.Flags, RequestID: p.RequestID, SequenceID: p.SequenceID, Body: p.Body,
}
}