chore: code adjustments

This commit is contained in:
Toby
2023-07-24 17:08:19 -07:00
parent cbedb27f0f
commit f0ad2f77ca
3 changed files with 30 additions and 20 deletions

View File

@@ -133,14 +133,19 @@ func (c *clientImpl) connect() error {
c.conn = conn
if udpEnabled {
c.udpSM = newUDPSessionManager(&udpIOImpl{Conn: conn})
go func() {
c.udpSM.Run()
// TODO: Mark connection as closed
}()
}
return nil
}
// openStream wraps the stream with QStream, which handles Close() properly
func (c *clientImpl) openStream() (quic.Stream, error) {
stream, err := c.conn.OpenStream()
if err != nil {
return nil, err
}
return &utils.QStream{Stream: stream}, nil
}
func (c *clientImpl) DialTCP(addr string) (net.Conn, error) {
stream, err := c.openStream()
if err != nil {
@@ -272,12 +277,3 @@ func (io *udpIOImpl) SendMessage(buf []byte, msg *protocol.UDPMessage) error {
}
return io.Conn.SendMessage(buf[:msgN])
}
// openStream wraps the stream with QStream, which handles Close() properly
func (c *clientImpl) openStream() (quic.Stream, error) {
stream, err := c.conn.OpenStream()
if err != nil {
return nil, err
}
return &utils.QStream{Stream: stream}, nil
}