Async::DiscordSourceAsyncDiscordGateway

class Gateway

Represents a gateway for the bot.

Definitions

def url

The URL of the gateway, used for connecting to the WebSocket server.

Implementation

def url
	self.value[:url]
end

def shards

The number of shards to use.

Implementation

def shards
	self.value[:shards]
end

def session_start_limit

Limits associated with this bot connecting to the gateway. You should respect these limits to avoid being rate limited.

Signature

returns Hash

the limits, including :total, :remaining, :reset_after, and :max_concurrency.

Implementation

def session_start_limit
	self.value[:session_start_limit]
end

def connect(shard: nil, &block)

Connect to the gateway, yielding the connection.

Signature

yields {|connection| ...}

if a block is given.

parameter connection GatewayConnection

The connection to the gateway.

returns GatewayConnection

the connection to the gateway.

Implementation

def connect(shard: nil, &block)
	endpoint = Async::HTTP::Endpoint.parse(self.url, alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
	
	Console.info(self, "Connecting to gateway...", endpoint: endpoint)
	Async::WebSocket::Client.connect(endpoint, handler: GatewayConnection, &block)
end