change StreamCallback to include the session

This commit is contained in:
Lucas Clemente 2016-04-18 14:01:35 +02:00
parent 57b144bdef
commit 07e7708506
2 changed files with 3 additions and 3 deletions

View file

@ -32,7 +32,7 @@ func main() {
} }
} }
func handleStream(stream *quic.Stream) []frames.Frame { func handleStream(session *quic.Session, stream *quic.Stream) []frames.Frame {
var reply bytes.Buffer var reply bytes.Buffer
h2framer := http2.NewFramer(&reply, stream) h2framer := http2.NewFramer(&reply, stream)
h2framer.ReadMetaHeaders = hpack.NewDecoder(1024, nil) h2framer.ReadMetaHeaders = hpack.NewDecoder(1024, nil)

View file

@ -13,7 +13,7 @@ import (
) )
// StreamCallback gets a stream frame and returns a reply frame // StreamCallback gets a stream frame and returns a reply frame
type StreamCallback func(*Stream) []frames.Frame type StreamCallback func(*Session, *Stream) []frames.Frame
// A Session is a QUIC session // A Session is a QUIC session
type Session struct { type Session struct {
@ -156,7 +156,7 @@ func (s *Session) handleStreamFrame(r *bytes.Reader) error {
} }
if !newStream { if !newStream {
replyFrames := s.streamCallback(stream) replyFrames := s.streamCallback(s, stream)
if replyFrames != nil { if replyFrames != nil {
s.SendFrames(replyFrames) s.SendFrames(replyFrames)
} }