shard

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GatewayDefaultURL = "wss://gateway.discord.gg/"
	GatewayVersion    = 10
	GatewayEncoding   = "json"
	GatewayAddressFmt = "%s/?v=%d&encoding=%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscordCloseCode

type DiscordCloseCode int64
const (
	CloseUnknownError DiscordCloseCode = iota + 4000
	CloseUnknownOpcode
	CloseDecodeError
	CloseNotAuthenticated
	CloseAuthenticationFailed
	CloseAlreadyAuthenticated

	CloseInvalidSeq
	CloseRateLimited
	CloseSessionTimeout
	CloseInvalidShard
	CloseShardingRequired
	CloseInvalidAPIVersion
	CloseInvalidIntents
	CloseDisallowedIntents
)

func (DiscordCloseCode) String

func (d DiscordCloseCode) String() string

type Heartbeat

type Heartbeat struct {
	// contains filtered or unexported fields
}

func NewHeartbeat

func NewHeartbeat(interval int64, shard *Shard, logger zerolog.Logger) *Heartbeat

func (*Heartbeat) ACK

func (h *Heartbeat) ACK()

func (*Heartbeat) SendHeartbeat

func (h *Heartbeat) SendHeartbeat() error

func (*Heartbeat) Start

func (h *Heartbeat) Start()

func (*Heartbeat) Stop

func (h *Heartbeat) Stop()

type IdentifyLocker added in v0.0.4

type IdentifyLocker interface {
	Lock()
	Unlock()
}

type ReadResult added in v0.0.5

type ReadResult struct {
	Payload objects.Payload
	Err     error
}

type Shard

type Shard struct {
	// contains filtered or unexported fields
}

Shard represents a single Shard connection

func New

func New(token string, opts ...ShardOption) *Shard

func (*Shard) Close

func (s *Shard) Close()

func (*Shard) IsIdentified

func (s *Shard) IsIdentified() bool

func (*Shard) Latency added in v0.0.12

func (s *Shard) Latency() time.Duration

func (*Shard) MarshalZerologObject added in v0.0.4

func (s *Shard) MarshalZerologObject(e *zerolog.Event)

func (*Shard) Run

func (s *Shard) Run() error

func (*Shard) Send

func (s *Shard) Send(op objects.OpCode, data interface{}) error

func (*Shard) String added in v0.0.4

func (s *Shard) String() string

type ShardError added in v0.0.5

type ShardError struct {
	Message string
}

func (ShardError) Error added in v0.0.5

func (s ShardError) Error() string

type ShardOption

type ShardOption func(*Shard)

func WithDispatcher

func WithDispatcher(d dispatcher.Dispatcher) ShardOption

func WithGatewayURL

func WithGatewayURL(u string) ShardOption

func WithIdentifyLock added in v0.0.4

func WithIdentifyLock(l IdentifyLocker) ShardOption

func WithInitialPresence

func WithInitialPresence(p objects.UpdatePresence) ShardOption

func WithIntents

func WithIntents(i objects.Intent) ShardOption

func WithLogger

func WithLogger(l zerolog.Logger) ShardOption

func WithShardInfo

func WithShardInfo(id, count int) ShardOption

type Websocket

type Websocket struct {
	// contains filtered or unexported fields
}

func NewWebsocket

func NewWebsocket(logger *zerolog.Logger) *Websocket

func (*Websocket) Close

func (w *Websocket) Close() error

func (*Websocket) IsConnected

func (w *Websocket) IsConnected() bool

func (*Websocket) Open

func (w *Websocket) Open(ctx context.Context, endpoint string, requestHeader http.Header) (err error)

func (*Websocket) Read

func (w *Websocket) Read(ctx context.Context) (data []byte, err error)

func (*Websocket) WriteJSON

func (w *Websocket) WriteJSON(v interface{}) error

Jump to

Keyboard shortcuts

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