internal static void Send <T>(this DiscordSocketClient client, GatewayOpcode op, T requestData) where T : new() { client.Socket.Send(JsonConvert.SerializeObject(new GatewayRequest <T>(op) { Data = requestData })); }
/// <inheritdoc/> public async Task SendAsync(int shardId, GatewayOpcode opcode, object payload) { if (Shards.TryGetValue(shardId, out var shard)) { await shard.SendAsync(shardId, opcode, payload); } }
internal static void Send <T>(this WebSocket socket, GatewayOpcode op, T requestData) where T : new() { socket.Send(JsonConvert.SerializeObject(new GatewayRequest <T>(op) { Data = requestData })); }
public GatewayRequest(GatewayOpcode opcode, string token) { Data = new T { Token = token }; Opcode = opcode; }
/// <inheritdoc/> public async Task SendAsync(int shardId, GatewayOpcode opcode, object payload) { if (payload == null) { throw new ArgumentNullException(nameof(payload)); } await connection.SendCommandAsync(opcode, payload, tokenSource.Token); }
public async ValueTask SendAsync(int shardId, GatewayOpcode opcode, object data) { var shard = GetConnection(shardId); if (shard == null) { Log.Debug("Shard not initialized in this cluster, ignoring payload."); return; } await shard.SendCommandAsync(opcode, data); }
public void Send <T>(GatewayOpcode op, T requestData) { lock (RequestLock) { if (Cooldown > DateTime.Now) { Thread.Sleep(Cooldown - DateTime.Now); } WebSocket.Send(op, requestData); Cooldown = DateTime.Now + new TimeSpan(0, 0, 0, 0, 500); } }
public async ValueTask SendAsync(int shardId, GatewayOpcode opCode, object payload) { if (!_initialized) { throw new InvalidOperationException("The cluster is not started yet."); } if (shardId < 0 || shardId >= _shards.Length) { throw new ArgumentOutOfRangeException(nameof(shardId)); } await _shards[shardId].SendAsync(shardId, opCode, payload); }
internal static void Send <T>(this DiscordSocketClient client, GatewayOpcode op, T requestData) where T : new() { lock (client.RequestLock) { if (client.Cooldown > DateTime.Now) { Thread.Sleep(client.Cooldown - DateTime.Now); } client.Socket.Send(JsonConvert.SerializeObject(new GatewayRequest <T>(op) { Data = requestData })); client.Cooldown = DateTime.Now + new TimeSpan(0, 0, 0, 0, 500); } }
public GatewayRequest(GatewayOpcode opcode) { Data = new T(); Opcode = opcode; }