Skip to content

Commit

Permalink
Gateway: Removed redundant context
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Feb 11, 2020
1 parent ff6669a commit 76c7760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 1 addition & 4 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,8 @@ func NewGatewayWithDriver(token string, driver json.Driver) (*Gateway, error) {
// Append the form to the URL
URL += "?" + param.Encode()

ctx, cancel := context.WithTimeout(context.Background(), g.WSTimeout)
defer cancel()

// Create a new undialed Websocket.
ws, err := wsutil.NewCustom(ctx, wsutil.NewConn(driver), URL)
ws, err := wsutil.NewCustom(wsutil.NewConn(driver), URL)
if err != nil {
return nil, errors.Wrap(err, "Failed to connect to Gateway "+URL)
}
Expand Down
8 changes: 3 additions & 5 deletions internal/wsutil/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ type Websocket struct {
dialed bool
}

func New(ctx context.Context, addr string) (*Websocket, error) {
return NewCustom(ctx, NewConn(json.Default{}), addr)
func New(addr string) (*Websocket, error) {
return NewCustom(NewConn(json.Default{}), addr)
}

// NewCustom creates a new undialed Websocket.
func NewCustom(
ctx context.Context, conn Connection, addr string) (*Websocket, error) {

func NewCustom(conn Connection, addr string) (*Websocket, error) {
ws := &Websocket{
Conn: conn,
Addr: addr,
Expand Down

0 comments on commit 76c7760

Please sign in to comment.