1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-02-09 21:16:51 +00:00

Gateway: Removed redundant context

This commit is contained in:
diamondburned 2020-02-11 09:29:30 -08:00
parent ff6669a58d
commit 76c7760c24
2 changed files with 4 additions and 9 deletions

View file

@ -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)
}

View file

@ -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,