qcc/internal/transport/stream.go
2026-06-30 12:52:09 +03:00

27 lines
475 B
Go

package transport
import (
"sync"
"github.com/apernet/quic-go"
"github.com/niko/qcc/internal/protocol"
)
type Stream struct {
q *quic.Stream
mu sync.Mutex
}
func NewStream(s *quic.Stream) *Stream {
return &Stream{q: s}
}
func (s *Stream) ReadFrame() (*protocol.Frame, error) {
return protocol.ReadFrame(s.q)
}
func (s *Stream) WriteFrame(opCode byte, payload []byte) error {
s.mu.Lock()
defer s.mu.Unlock()
return protocol.WriteFrame(s.q, opCode, payload)
}