multiplex.go
func NewMultiplex(con net.Conn, initiator bool) *Multiplex {
	mp := &Multiplex{
		con:       con,
		initiator: initiator,
		buf:       bufio.NewReader(con),
		channels:  make(map[streamID]*Stream),
		closed:    make(chan struct{}),
		shutdown:  make(chan struct{}),
		wrTkn:     make(chan struct{}, 1),
		nstreams:  make(chan *Stream, 16),
	}

	go mp.handleIncoming()

	mp.wrTkn <- struct{}{}

	return mp
}
func NewMultiplex(con net.Conn, initiator bool) *Multiplex {
	mp := &Multiplex{
		con:       con,
		initiator: initiator,
		buf:       bufio.NewReader(con),
		channels:  make(map[streamID]*Stream),
		closed:    make(chan struct{}),
		shutdown:  make(chan struct{}),
		wrTkn:     make(chan struct{}, 1),
		nstreams:  make(chan *Stream, 16),
	}

	go mp.handleIncoming()

	mp.wrTkn <- struct{}{}

	return mp
}
// NewMultiplex creates a new multiplexer session.