func (mp *Multiplex) NewNamedStream(name string) (*Stream, error) {
	mp.chLock.Lock()

	// We could call IsClosed but this is faster (given that we already have
	// the lock).
	if mp.channels == nil {
		mp.chLock.Unlock()
		return nil, ErrShutdown
	}

	sid := mp.nextChanID()
	header := (sid << 3) | newStreamTag

	if name == "" {
		name = fmt.Sprint(sid)
	}
	s := mp.newStream(streamID{
		id:        sid,
		initiator: true,
	}, name)
	mp.channels[s.id] = s
	mp.chLock.Unlock()

	err := mp.sendMsg(context.Background(), header, []byte(name))
	if err != nil {
		return nil, err
	}

	return s, nil
}
func (mp *Multiplex) NewNamedStream(name string) (*Stream, error) {
	mp.chLock.Lock()

	
	
	if mp.channels == nil {
		mp.chLock.Unlock()
		return nil, ErrShutdown
	}

	sid := mp.nextChanID()
	header := (sid << 3) | newStreamTag

	if name == "" {
		name = fmt.Sprint(sid)
	}
	s := mp.newStream(streamID{
		id:        sid,
		initiator: true,
	}, name)
	mp.channels[s.id] = s
	mp.chLock.Unlock()

	err := mp.sendMsg(context.Background(), header, []byte(name))
	if err != nil {
		return nil, err
	}

	return s, nil
}
func ( mp * Multiplex ) NewNamedStream ( name string ) ( * Stream , error ) { mp . chLock . Lock ( ) // We could call IsClosed but this is faster (given that we already have // the lock). if mp . channels == nil { mp . chLock . Unlock ( ) return nil , ErrShutdown } sid := mp . nextChanID ( ) header := ( sid << 3 ) | newStreamTag if name == " " { name = fmt . Sprint ( sid ) } s := mp . newStream ( streamID { id : sid , initiator : true , } , name ) mp . channels [ s . id ] = s mp . chLock . Unlock ( ) err := mp . sendMsg ( context . Background ( ) , header , [ ] byte ( name ) ) if err != nil { return nil , err } return s , nil }
// NewNamedStream creates a new named stream.
NewNamedStream creates a new named stream .