Changed ids to uint64s
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Discord.API
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
[JsonConverter(typeof(LongStringConverter))]
|
||||
public long ServerId;
|
||||
public ulong ServerId;
|
||||
[JsonProperty("endpoint")]
|
||||
public string Endpoint;
|
||||
[JsonProperty("token")]
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace Discord.API
|
||||
{
|
||||
[JsonProperty("server_id")]
|
||||
[JsonConverter(typeof(LongStringConverter))]
|
||||
public long ServerId;
|
||||
public ulong ServerId;
|
||||
[JsonProperty("user_id")]
|
||||
[JsonConverter(typeof(LongStringConverter))]
|
||||
public long UserId;
|
||||
public ulong UserId;
|
||||
[JsonProperty("session_id")]
|
||||
public string SessionId;
|
||||
[JsonProperty("token")]
|
||||
@@ -102,7 +102,7 @@ namespace Discord.API
|
||||
{
|
||||
[JsonProperty("user_id")]
|
||||
[JsonConverter(typeof(LongStringConverter))]
|
||||
public long UserId;
|
||||
public ulong UserId;
|
||||
[JsonProperty("ssrc")]
|
||||
public uint SSRC;
|
||||
[JsonProperty("speaking")]
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Discord.Audio
|
||||
{
|
||||
public class VoiceDisconnectedEventArgs : DisconnectedEventArgs
|
||||
{
|
||||
public readonly long ServerId;
|
||||
public readonly ulong ServerId;
|
||||
|
||||
public VoiceDisconnectedEventArgs(long serverId, DisconnectedEventArgs e)
|
||||
public VoiceDisconnectedEventArgs(ulong serverId, DisconnectedEventArgs e)
|
||||
: base(e.WasUnexpected, e.Error)
|
||||
{
|
||||
ServerId = serverId;
|
||||
@@ -28,13 +28,13 @@ namespace Discord.Audio
|
||||
}
|
||||
public class VoicePacketEventArgs : EventArgs
|
||||
{
|
||||
public readonly long UserId;
|
||||
public readonly long ChannelId;
|
||||
public readonly ulong UserId;
|
||||
public readonly ulong ChannelId;
|
||||
public readonly byte[] Buffer;
|
||||
public readonly int Offset;
|
||||
public readonly int Count;
|
||||
|
||||
public VoicePacketEventArgs(long userId, long channelId, byte[] buffer, int offset, int count)
|
||||
public VoicePacketEventArgs(ulong userId, ulong channelId, byte[] buffer, int offset, int count)
|
||||
{
|
||||
UserId = userId;
|
||||
ChannelId = channelId;
|
||||
@@ -47,7 +47,7 @@ namespace Discord.Audio
|
||||
public class AudioService : IService
|
||||
{
|
||||
private DiscordAudioClient _defaultClient;
|
||||
private ConcurrentDictionary<long, DiscordAudioClient> _voiceClients;
|
||||
private ConcurrentDictionary<ulong, DiscordAudioClient> _voiceClients;
|
||||
private ConcurrentDictionary<User, bool> _talkingUsers;
|
||||
private int _nextClientId;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Discord.Audio
|
||||
Connected(this, EventArgs.Empty);
|
||||
}
|
||||
public event EventHandler<VoiceDisconnectedEventArgs> Disconnected;
|
||||
private void RaiseDisconnected(long serverId, DisconnectedEventArgs e)
|
||||
private void RaiseDisconnected(ulong serverId, DisconnectedEventArgs e)
|
||||
{
|
||||
if (Disconnected != null)
|
||||
Disconnected(this, new VoiceDisconnectedEventArgs(serverId, e));
|
||||
@@ -91,7 +91,7 @@ namespace Discord.Audio
|
||||
{
|
||||
_client = client;
|
||||
if (Config.EnableMultiserver)
|
||||
_voiceClients = new ConcurrentDictionary<long, DiscordAudioClient>();
|
||||
_voiceClients = new ConcurrentDictionary<ulong, DiscordAudioClient>();
|
||||
else
|
||||
{
|
||||
var logger = Client.Log().CreateLogger("Voice");
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Discord.Audio
|
||||
public string Token => _token;
|
||||
private string _token;
|
||||
|
||||
public long? ServerId => _voiceSocket.ServerId;
|
||||
public long? ChannelId => _voiceSocket.ChannelId;
|
||||
public ulong? ServerId => _voiceSocket.ServerId;
|
||||
public ulong? ChannelId => _voiceSocket.ChannelId;
|
||||
|
||||
public DiscordAudioClient(AudioService service, int id, Logger logger, GatewaySocket gatewaySocket)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace Discord.Audio
|
||||
case "VOICE_SERVER_UPDATE":
|
||||
{
|
||||
var data = e.Payload.ToObject<VoiceServerUpdateEvent>(_gatewaySocket.Serializer);
|
||||
long serverId = data.ServerId;
|
||||
var serverId = data.ServerId;
|
||||
|
||||
if (serverId == ServerId)
|
||||
{
|
||||
@@ -101,14 +101,14 @@ namespace Discord.Audio
|
||||
return _voiceSocket.Disconnect();
|
||||
}
|
||||
|
||||
internal void SetServerId(long serverId)
|
||||
internal void SetServerId(ulong serverId)
|
||||
{
|
||||
_voiceSocket.ServerId = serverId;
|
||||
}
|
||||
public async Task Join(Channel channel)
|
||||
{
|
||||
if (channel == null) throw new ArgumentNullException(nameof(channel));
|
||||
long? serverId = channel.Server?.Id;
|
||||
ulong? serverId = channel.Server?.Id;
|
||||
if (serverId != ServerId)
|
||||
throw new InvalidOperationException("Cannot join a channel on a different server than this voice client.");
|
||||
//CheckReady(checkVoice: true);
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Discord.Net.WebSockets
|
||||
{
|
||||
internal sealed class IsTalkingEventArgs : EventArgs
|
||||
{
|
||||
public readonly long UserId;
|
||||
public readonly ulong UserId;
|
||||
public readonly bool IsSpeaking;
|
||||
internal IsTalkingEventArgs(long userId, bool isTalking)
|
||||
internal IsTalkingEventArgs(ulong userId, bool isTalking)
|
||||
{
|
||||
UserId = userId;
|
||||
IsSpeaking = isTalking;
|
||||
@@ -17,14 +17,14 @@ namespace Discord.Net.WebSockets
|
||||
public partial class VoiceWebSocket
|
||||
{
|
||||
internal event EventHandler<IsTalkingEventArgs> IsSpeaking;
|
||||
private void RaiseIsSpeaking(long userId, bool isSpeaking)
|
||||
private void RaiseIsSpeaking(ulong userId, bool isSpeaking)
|
||||
{
|
||||
if (IsSpeaking != null)
|
||||
IsSpeaking(this, new IsTalkingEventArgs(userId, isSpeaking));
|
||||
}
|
||||
|
||||
internal event EventHandler<VoicePacketEventArgs> OnPacket;
|
||||
internal void RaiseOnPacket(long userId, long channelId, byte[] buffer, int offset, int count)
|
||||
internal void RaiseOnPacket(ulong userId, ulong channelId, byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (OnPacket != null)
|
||||
OnPacket(this, new VoicePacketEventArgs(userId, channelId, buffer, offset, count));
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Discord.Net.WebSockets
|
||||
private readonly AudioServiceConfig _config;
|
||||
private OpusEncoder _encoder;
|
||||
private uint _ssrc;
|
||||
private ConcurrentDictionary<uint, long> _ssrcMapping;
|
||||
private ConcurrentDictionary<uint, ulong> _ssrcMapping;
|
||||
|
||||
private VoiceBuffer _sendBuffer;
|
||||
private UdpClient _udp;
|
||||
@@ -38,14 +38,14 @@ namespace Discord.Net.WebSockets
|
||||
private bool _isEncrypted;
|
||||
private byte[] _secretKey, _encodingBuffer;
|
||||
private ushort _sequence;
|
||||
private long? _serverId, _channelId;
|
||||
private ulong? _serverId, _channelId;
|
||||
private string _encryptionMode;
|
||||
private int _ping;
|
||||
|
||||
private Thread _sendThread, _receiveThread;
|
||||
|
||||
public long? ServerId { get { return _serverId; } internal set { _serverId = value; } }
|
||||
public long? ChannelId { get { return _channelId; } internal set { _channelId = value; } }
|
||||
public ulong? ServerId { get { return _serverId; } internal set { _serverId = value; } }
|
||||
public ulong? ChannelId { get { return _channelId; } internal set { _channelId = value; } }
|
||||
public int Ping => _ping;
|
||||
internal VoiceBuffer OutputBuffer => _sendBuffer;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Discord.Net.WebSockets
|
||||
_decoders = new ConcurrentDictionary<uint, OpusDecoder>();
|
||||
_targetAudioBufferLength = _config.BufferLength / 20; //20 ms frames
|
||||
_encodingBuffer = new byte[MaxOpusSize];
|
||||
_ssrcMapping = new ConcurrentDictionary<uint, long>();
|
||||
_ssrcMapping = new ConcurrentDictionary<uint, ulong>();
|
||||
_encoder = new OpusEncoder(48000, _config.Channels, 20, _config.Bitrate, OpusApplication.Audio);
|
||||
_sendBuffer = new VoiceBuffer((int)Math.Ceiling(_config.BufferLength / (double)_encoder.FrameLength), _encoder.FrameSize);
|
||||
}
|
||||
@@ -228,10 +228,10 @@ namespace Discord.Net.WebSockets
|
||||
resultLength = packetLength - 12;
|
||||
}
|
||||
|
||||
/*if (_logLevel >= LogMessageSeverity.Debug)
|
||||
/*if (_logLevel >= LogMessageSeverity.Debug)
|
||||
RaiseOnLog(LogMessageSeverity.Debug, $"Received {buffer.Length - 12} bytes.");*/
|
||||
|
||||
long userId;
|
||||
ulong userId;
|
||||
if (_ssrcMapping.TryGetValue(ssrc, out userId))
|
||||
RaiseOnPacket(userId, _channelId.Value, result, resultOffset, resultLength);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user