Ejemplo n.º 1
0
        internal DiscordVoiceConnection(Shard shard, Snowflake guildId)
        {
            this.shard   = shard;
            this.guildId = guildId;

            cache   = shard.Cache;
            gateway = (Gateway)shard.Gateway;

            isValid = true;
        }
Ejemplo n.º 2
0
        internal ShardVoiceManager(Shard shard, Gateway gateway)
        {
            this.shard   = shard;
            this.gateway = gateway;

            cache = shard.Cache;

            voiceConnections  = new ConcurrentDictionary <Snowflake, DiscordVoiceConnection>();
            voiceChannelUsers = new ConcurrentDictionary <Snowflake, ConcurrentHashSet <Snowflake> >();
        }
Ejemplo n.º 3
0
        internal Gateway(string botToken, Shard shard, int totalShards)
        {
            this.botToken    = botToken;
            this.shard       = shard;
            this.totalShards = totalShards;

            http = new DiscordHttpClient(botToken);

            cache = shard.Cache;

            log   = new DiscoreLogger($"Gateway#{shard.Id}");
            state = GatewayState.Disconnected;

            handshakeCompleteEvent = new AsyncManualResetEvent();
            handshakeCompleteCancellationSource = new CancellationTokenSource();

            // Up-to-date rate limit parameters: https://discord.com/developers/docs/topics/gateway#rate-limiting
            identifyRateLimiter         = new GatewayRateLimiter(5, 1);    // 1 IDENTIFY per 5 seconds
            outboundPayloadRateLimiter  = new GatewayRateLimiter(60, 120); // 120 outbound payloads every 60 seconds
            gameStatusUpdateRateLimiter = new GatewayRateLimiter(60, 5);   // 5 status updates per minute

            InitializeDispatchHandlers();
        }