diff --git a/mux.go b/mux.go index 7628ecc..8b8a947 100644 --- a/mux.go +++ b/mux.go @@ -3,11 +3,11 @@ package smux import "io" // Server is used to initialize a new server-side connection. -func Server(conn io.ReadWriteCloser, maxframes, framesize int) (*Session, error) { +func Server(conn io.ReadWriteCloser, maxframes int, framesize uint16) (*Session, error) { return newSession(conn, false, maxframes, framesize), nil } // Client is used to initialize a new client-side connection. -func Client(conn io.ReadWriteCloser, maxframes, framesize int) (*Session, error) { +func Client(conn io.ReadWriteCloser, maxframes int, framesize uint16) (*Session, error) { return newSession(conn, true, maxframes, framesize), nil } diff --git a/session.go b/session.go index ee159e5..0a1a83d 100644 --- a/session.go +++ b/session.go @@ -21,7 +21,7 @@ type Session struct { // stream related nextStreamID uint32 streams map[uint32]*Stream - frameSize int + frameSize uint16 // rx pool control tokens chan struct{} @@ -47,7 +47,7 @@ func (lw *lockedWriter) Write(p []byte) (n int, err error) { return } -func newSession(conn io.ReadWriteCloser, client bool, maxframes, framesize int) *Session { +func newSession(conn io.ReadWriteCloser, client bool, maxframes int, framesize uint16) *Session { s := new(Session) s.conn = conn s.frameSize = framesize diff --git a/stream.go b/stream.go index dc0f54e..3a59695 100644 --- a/stream.go +++ b/stream.go @@ -13,13 +13,13 @@ type Stream struct { id uint32 chNotifyReader chan struct{} sess *Session - frameSize int + frameSize uint16 die chan struct{} rlock sync.Mutex buffer []byte } -func newStream(id uint32, frameSize int, chNotifyReader chan struct{}, sess *Session) *Stream { +func newStream(id uint32, frameSize uint16, chNotifyReader chan struct{}, sess *Session) *Stream { s := new(Stream) s.id = id s.chNotifyReader = chNotifyReader @@ -108,7 +108,7 @@ func (s *Stream) Close() error { func (s *Stream) split(bts []byte, cmd byte, sid uint32) []Frame { var frames []Frame - for len(bts) > s.frameSize { + for len(bts) > int(s.frameSize) { frame := newFrame(cmd, sid) frame.data = make([]byte, s.frameSize) n := copy(frame.data, bts)