Skip to content

Commit

Permalink
Support For Resume Gateway URL
Browse files Browse the repository at this point in the history
Added Support for Resume Gateway URL. 
Although [this pull request](spec-tacles/go#9) needs to be closed prior to approving this.
  • Loading branch information
infinitytmbots authored May 18, 2024
1 parent 84f795f commit a4569d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gateway/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Shard struct {
limiter Limiter
packets *sync.Pool
lastHeartbeat time.Time
resumeURL string

connMu sync.Mutex
acks chan struct{}
Expand All @@ -47,6 +48,7 @@ func NewShard(opts *ShardOptions) *Shard {
},
id: strconv.Itoa(opts.Identify.Shard[0]),
acks: make(chan struct{}),
resumeURL: "",
}
}

Expand Down Expand Up @@ -265,6 +267,8 @@ func (s *Shard) handleDispatch(ctx context.Context, p *types.ReceivePacket) (err
return
}

s.resumeURL = r.ResumeGatewayURL

Check failure on line 270 in gateway/shard.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

r.ResumeGatewayURL undefined (type *types.Ready has no field or method ResumeGatewayURL)

if err = s.opts.Store.SetSession(ctx, s.idUint(), r.SessionID); err != nil {
return
}
Expand Down Expand Up @@ -422,7 +426,11 @@ func (s *Shard) gatewayURL() string {
"compress": {"zstd-stream"},
}

return s.Gateway.URL + "/?" + query.Encode()
if s.resumeURL != "" {
return s.resumeURL + "/?" + query.Encode()
} else {
return s.Gateway.URL + "/?" + query.Encode()
}
}

func (s *Shard) idUint() uint {
Expand Down

0 comments on commit a4569d2

Please sign in to comment.