1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 18:53:30 +00:00

gateway: Expose GatewayOpts getter

This commit is contained in:
diamondburned 2022-11-18 02:01:18 -08:00
parent 78ad477b83
commit 5a156cc699
No known key found for this signature in database
GPG key ID: D78C4471CE776659
2 changed files with 12 additions and 1 deletions

View file

@ -171,13 +171,17 @@ func NewFromState(gatewayURL string, state State, opts *ws.GatewayOpts) *Gateway
}
gw := ws.NewGateway(ws.NewWebsocket(ws.NewCodec(OpUnmarshalers), gatewayURL), opts)
return &Gateway{
gateway: gw,
state: state,
}
}
// Opts returns a copy of the gateway options that are being used.
func (g *Gateway) Opts() *ws.GatewayOpts {
return g.gateway.Opts()
}
// State returns a copy of the gateway's internal state. It panics if the
// gateway is currently running.
func (g *Gateway) State() State {

View file

@ -159,6 +159,13 @@ func NewGateway(ws *Websocket, opts *GatewayOpts) *Gateway {
}
}
// Opts returns a copy of the gateway options. The options can only be changed
// during construction, so a copy is a must.
func (g *Gateway) Opts() *GatewayOpts {
cpy := g.opts
return &cpy
}
// Send is a function to send an Op payload to the Gateway.
func (g *Gateway) Send(ctx context.Context, data Event) error {
op := Op{