コード例 #1
0
 internal Shard(DiscordSharder sharder, DiscordClientGateway gateway)
 {
     _sharder = sharder;
     _gateway = gateway;
     Id       = gateway.ShardId.Value;
     Guilds   = new ReadOnlyValuePredicateArgumentDictionary <Snowflake, CachedGuild, Shard>(
         _sharder.Guilds, (x, shard) => shard._sharder.GetShardId(x.Id) == shard.Id, this);
 }
コード例 #2
0
        public IdentifyLock(DiscordClientGateway gateway)
        {
            _gateway = gateway;

            // TODO: tie this to application id?
            // TODO: persistence?
            _semaphore = _semaphores.GetOrAdd(gateway.Client.Token, _ => new SemaphoreSlim(1, 1));
        }
コード例 #3
0
ファイル: DiscordSharder.Gateway.cs プロジェクト: Miimik/test
        internal Task InternalSetPresenceAsync(DiscordClientGateway gateway, UserStatus?status = default, Optional <LocalActivity> activity = default)
        {
            ThrowIfDisposed();

            if (!status.HasValue && !activity.HasValue)
            {
                return(Task.CompletedTask);
            }

            if (status.HasValue)
            {
                gateway.SetStatus(status.Value);
            }

            if (activity.HasValue)
            {
                gateway.SetActivity(activity.Value);
            }

            return(gateway.SendPresenceAsync());
        }