public async Task SendIdentifyAsync(int largeThreshold = 100, int shardID = 0, int totalShards = 1, bool guildSubscriptions = true, GatewayIntents?gatewayIntents = null, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); var props = new Dictionary <string, string> { ["$device"] = "Discord.Net" }; var msg = new IdentifyParams() { Token = AuthToken, Properties = props, LargeThreshold = largeThreshold }; if (totalShards > 1) { msg.ShardingParams = new int[] { shardID, totalShards } } ; options.BucketId = GatewayBucket.Get(GatewayBucketType.Identify).Id; if (gatewayIntents.HasValue) { msg.Intents = (int)gatewayIntents.Value; } else { msg.GuildSubscriptions = guildSubscriptions; } await SendGatewayAsync(GatewayOpCode.Identify, msg, options : options).ConfigureAwait(false); }
private async Task SendGatewayInternalAsync(GatewayOpCode opCode, object payload, RequestOptions options) { CheckState(); //TODO: Add ETF byte[] bytes = null; payload = new SocketFrame { Operation = (int)opCode, Payload = payload }; if (payload != null) { bytes = Encoding.UTF8.GetBytes(SerializeJson(payload)); } options.IsGatewayBucket = true; if (options.BucketId == null) { options.BucketId = GatewayBucket.Get(GatewayBucketType.Unbucketed).Id; } await RequestQueue.SendAsync(new WebSocketRequest(WebSocketClient, bytes, true, opCode == GatewayOpCode.Heartbeat, options)).ConfigureAwait(false); await _sentGatewayMessageEvent.InvokeAsync(opCode).ConfigureAwait(false); #if DEBUG_PACKETS Console.WriteLine($"-> {opCode}:\n{SerializeJson(payload)}"); #endif }
public async Task SendStatusUpdateAsync(UserStatus status, bool isAFK, long?since, Game game, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); var args = new StatusUpdateParams { Status = status, IdleSince = since, IsAFK = isAFK, Game = game }; options.BucketId = GatewayBucket.Get(GatewayBucketType.PresenceUpdate).Id; await SendGatewayAsync(GatewayOpCode.StatusUpdate, args, options : options).ConfigureAwait(false); }
public CachingService(BrandBucket brandBucket , CountryBucket countryBucket , CurrencyBucket currencyBucket , GatewayBucket gatewayBucket , SourceMarketBucket sourceMarketBucket , TourOperatorBucket tourOperatorBucket , HotelBucket hotelBucket) { this.brandBucket = brandBucket; this.countryBucket = countryBucket; this.currencyBucket = currencyBucket; this.gatewayBucket = gatewayBucket; this.sourceMarketBucket = sourceMarketBucket; this.tourOperatorBucket = tourOperatorBucket; this.hotelBucket = hotelBucket; }
public BookingService(BrandBucket brandBucket , CountryBucket countryBucket , CurrencyBucket currencyBucket , GatewayBucket gatewayBucket , SourceMarketBucket sourceMarketBucket , TourOperatorBucket tourOperatorBucket , HotelBucket hotelBucket) { this.brandBucket = brandBucket; this.countryBucket = countryBucket; this.currencyBucket = currencyBucket; this.gatewayBucket = gatewayBucket; this.sourceMarketBucket = sourceMarketBucket; this.tourOperatorBucket = tourOperatorBucket; this.hotelBucket = hotelBucket; if (this.brandBucket.Items == null || this.brandBucket.Items.Count == 0) { this.brandBucket.FillBucket(); } if (this.countryBucket.Items == null || this.countryBucket.Items.Count == 0) { this.countryBucket.FillBucket(); } if (this.currencyBucket.Items == null || this.currencyBucket.Items.Count == 0) { this.currencyBucket.FillBucket(); } if (this.gatewayBucket.Items == null || this.gatewayBucket.Items.Count == 0) { this.gatewayBucket.FillBucket(); } if (this.sourceMarketBucket.Items == null || this.sourceMarketBucket.Items.Count == 0) { this.sourceMarketBucket.FillBucket(); } if (this.tourOperatorBucket.Items == null || this.tourOperatorBucket.Items.Count == 0) { this.tourOperatorBucket.FillBucket(); } if (this.hotelBucket.Items == null || this.hotelBucket.Items.Count == 0) { this.hotelBucket.FillBucket(); } }