Browse Source

Minor tweaks

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
061db73f03
2 changed files with 17 additions and 12 deletions
  1. +1
    -1
      src/Discord.Net/Channel.cs
  2. +16
    -11
      src/Discord.Net/DiscordClient.cs

+ 1
- 1
src/Discord.Net/Channel.cs View File

@@ -21,7 +21,7 @@ namespace Discord


private string _name; private string _name;
/// <summary> Returns the name of this channel. </summary> /// <summary> Returns the name of this channel. </summary>
public string Name { get { return !IsPrivate ? $"#{_name}" : $"@{Recipient.Name}"; } internal set { _name = value; } }
public string Name { get { return !IsPrivate ? $"{_name}" : $"@{Recipient.Name}"; } internal set { _name = value; } }


/// <summary> Returns the position of this channel in the channel list for this server. </summary> /// <summary> Returns the position of this channel in the channel list for this server. </summary>
public int Position { get; internal set; } public int Position { get; internal set; }


+ 16
- 11
src/Discord.Net/DiscordClient.cs View File

@@ -26,7 +26,6 @@ namespace Discord
private readonly JsonSerializer _serializer; private readonly JsonSerializer _serializer;
private readonly Random _rand; private readonly Random _rand;


private volatile CancellationTokenSource _disconnectToken;
private volatile Task _tasks; private volatile Task _tasks;
private string _currentVoiceServerId, _currentVoiceEndpoint, _currentVoiceToken; private string _currentVoiceServerId, _currentVoiceEndpoint, _currentVoiceToken;


@@ -68,7 +67,13 @@ namespace Discord
/// <summary> Returns true if the user has successfully logged in and the websocket connection has been established. </summary> /// <summary> Returns true if the user has successfully logged in and the websocket connection has been established. </summary>
public bool IsConnected => _isConnected; public bool IsConnected => _isConnected;
private bool _isConnected; private bool _isConnected;

private volatile CancellationTokenSource _disconnectToken;
/// <summary> Returns true if this client was requested to disconnect. </summary>
public bool IsClosing => _disconnectToken.IsCancellationRequested;
/// <summary> Returns a cancel token that is triggered when a disconnect is requested. </summary>
public CancellationToken CloseToken => _disconnectToken.Token;

/// <summary> Initializes a new instance of the DiscordClient class. </summary> /// <summary> Initializes a new instance of the DiscordClient class. </summary>
public DiscordClient(DiscordClientConfig config = null) public DiscordClient(DiscordClientConfig config = null)
{ {
@@ -1228,20 +1233,20 @@ namespace Discord




//Voice //Voice
public Task JoinVoice(Server server, Channel channel)
=> JoinVoice(server.Id, channel.Id);
public Task JoinVoice(Server server, string channelId)
=> JoinVoice(server.Id, channelId);
public Task JoinVoice(string serverId, Channel channel)
=> JoinVoice(serverId, channel.Id);
public async Task JoinVoice(string serverId, string channelId)
public Task JoinVoiceServer(Server server, Channel channel)
=> JoinVoiceServer(server.Id, channel.Id);
public Task JoinVoiceServer(Server server, string channelId)
=> JoinVoiceServer(server.Id, channelId);
public Task JoinVoiceServer(string serverId, Channel channel)
=> JoinVoiceServer(serverId, channel.Id);
public async Task JoinVoiceServer(string serverId, string channelId)
{ {
await LeaveVoice();
await LeaveVoiceServer();
_currentVoiceServerId = serverId; _currentVoiceServerId = serverId;
_webSocket.JoinVoice(serverId, channelId); _webSocket.JoinVoice(serverId, channelId);
} }


public async Task LeaveVoice()
public async Task LeaveVoiceServer()
{ {
await _voiceWebSocket.DisconnectAsync(); await _voiceWebSocket.DisconnectAsync();
if (_currentVoiceEndpoint != null) if (_currentVoiceEndpoint != null)


Loading…
Cancel
Save