gateway

package
v0.0.0-...-84acdea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GatewayConnector

type GatewayConnector struct {
	// Public State
	SessionState GatewayConnectorOptionsResume // The state of the session
	// contains filtered or unexported fields
}

GatewayConnector represents a connection to the discord gateway for a shard

func NewGateway

func NewGateway(options GatewayConnectorOptions) *GatewayConnector

NewGateway creates a connector instance based on the given options.

func (*GatewayConnector) Start

func (discord *GatewayConnector) Start()

Start is used to start or reset a connection to the gateway.

type GatewayConnectorOptions

type GatewayConnectorOptions struct {
	Token         *string                       // The token of the bot
	SelfShard     *int                          // The shard of the current connector
	TotalShard    *int                          // The total count of shards
	Intend        types.GatewayIntents          // The bitflags for the indents.
	GuildSubs     *bool                         // Should the guild_subscriptions be enabled
	ResumeSession GatewayConnectorOptionsResume // Is specified, the gateway will try to resume a connection.
	Compressor    gateway.Compression           // The compressor given to the gateway that determine the connection method and compression used.
	Transporter   gateway.Transporter           // The interface where we send the data.
	Restart       *bool                         // Should the gateway restart upon failure.

	OnSessionStateUpdated  func(state GatewayConnectorOptionsResume) error // When the session state is called, we call this function
	SessionUpdateFrequency *int
}

GatewayConnectorOptions is the options given to the GatewayConnector when creating it.

type GatewayConnectorOptionsResume

type GatewayConnectorOptionsResume struct {
	Session string `json:"session_id"` // The session id of the older session we want to resume.
	Index   int64  `json:"index"`      // The index of the last packet recevied by the older session.
}

GatewayConnectorOptionsResume represents the options for reconnecting the gateway.

type GatewayConnectorOptionsSharding

type GatewayConnectorOptionsSharding struct {
	TotalShards  int `json:"total_shards"`  // The total amount of shards
	CurrentShard int `json:"current_shard"` // The shard we want to connect to.
}

GatewayConnectorOptionsSharding represents the options for sharding the gateway.

type NovaMessage

type NovaMessage struct {
	Data    json.RawMessage `json:"data"`
	Tracing struct {
		NodeName string `json:"node_name"`
	} `json:"tracing"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL