26 lines
583 B
Go
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,
|
|
}
|
|
}
|