Skip to content

Commit

Permalink
feat: add Hijack()
Browse files Browse the repository at this point in the history
  • Loading branch information
sujit-baniya committed Oct 18, 2023
1 parent 6f67d3c commit 4e8e2b5
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 732 deletions.
90 changes: 0 additions & 90 deletions pkg/websocket/config.go

This file was deleted.

23 changes: 2 additions & 21 deletions pkg/websocket/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ type Conn struct {
writeBufSize int
writeDeadline time.Time
writer io.WriteCloser // the current writer returned to the application
isWriting bool // for best-effort concurrent write detection

writeErrMu sync.Mutex
writeErr error
Expand Down Expand Up @@ -613,18 +612,8 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
// concurrent writes. See the concurrency section in the package
// documentation for more info.

if c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = true

err := c.write(w.frameType, c.writeDeadline, c.writeBuf[framePos:w.pos], extra)

if !c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = false

if err != nil {
return w.endMessage(err)
}
Expand Down Expand Up @@ -741,16 +730,8 @@ func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
if err != nil {
return err
}
if c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = true
err = c.write(frameType, c.writeDeadline, frameData, nil)
if !c.isWriting {
panic("concurrent write to websocket connection")
}
c.isWriting = false
return err

return c.write(frameType, c.writeDeadline, frameData, nil)
}

// WriteMessage is a helper method for getting a writer using NextWriter,
Expand Down
7 changes: 0 additions & 7 deletions pkg/websocket/envelope.go

This file was deleted.

91 changes: 0 additions & 91 deletions pkg/websocket/hub.go

This file was deleted.

Loading

0 comments on commit 4e8e2b5

Please sign in to comment.