From 76c7760c24e9669bccec1c510a77348d28db5315 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 11 Feb 2020 09:29:30 -0800 Subject: [PATCH] Gateway: Removed redundant context --- gateway/gateway.go | 5 +---- internal/wsutil/ws.go | 8 +++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/gateway/gateway.go b/gateway/gateway.go index 830b5d4e..5e786569 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -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) } diff --git a/internal/wsutil/ws.go b/internal/wsutil/ws.go index b758770f..4fb42c94 100644 --- a/internal/wsutil/ws.go +++ b/internal/wsutil/ws.go @@ -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,