Started Discord.Net.Relay
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Discord.Net.Relay")]
|
||||
[assembly: InternalsVisibleTo("Discord.Net.Tests")]
|
||||
@@ -33,10 +33,11 @@ namespace Discord.API
|
||||
|
||||
public ConnectionState ConnectionState { get; private set; }
|
||||
|
||||
public DiscordSocketApiClient(RestClientProvider restClientProvider, string userAgent, WebSocketProvider webSocketProvider,
|
||||
RetryMode defaultRetryMode = RetryMode.AlwaysRetry, JsonSerializer serializer = null)
|
||||
public DiscordSocketApiClient(RestClientProvider restClientProvider, WebSocketProvider webSocketProvider, string userAgent,
|
||||
string url = null, RetryMode defaultRetryMode = RetryMode.AlwaysRetry, JsonSerializer serializer = null)
|
||||
: base(restClientProvider, userAgent, defaultRetryMode, serializer)
|
||||
{
|
||||
{
|
||||
_gatewayUrl = url;
|
||||
WebSocketClient = webSocketProvider();
|
||||
//WebSocketClient.SetHeader("user-agent", DiscordConfig.UserAgent); (Causes issues in .NET Framework 4.6+)
|
||||
WebSocketClient.BinaryMessage += async (data, index, count) =>
|
||||
@@ -115,9 +116,9 @@ namespace Discord.API
|
||||
|
||||
ConnectionState = ConnectionState.Connected;
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
_gatewayUrl = null; //Uncache in case the gateway url changed
|
||||
_gatewayUrl = null; //Uncache in case the gateway url changed
|
||||
await DisconnectInternalAsync().ConfigureAwait(false);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Discord.WebSocket
|
||||
_largeGuilds = new ConcurrentQueue<ulong>();
|
||||
}
|
||||
private static API.DiscordSocketApiClient CreateApiClient(DiscordSocketConfig config)
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, config.WebSocketProvider, DiscordRestConfig.UserAgent);
|
||||
=> new API.DiscordSocketApiClient(config.RestClientProvider, config.WebSocketProvider, DiscordRestConfig.UserAgent, config.GatewayHost);
|
||||
|
||||
protected override async Task OnLoginAsync(TokenType tokenType, string token)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Discord.Net.Udp;
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
@@ -10,6 +9,9 @@ namespace Discord.WebSocket
|
||||
{
|
||||
public const string GatewayEncoding = "json";
|
||||
|
||||
/// <summary> Gets or sets the websocket host to connect to. If null, the client will use the /gateway endpoint.
|
||||
public string GatewayHost { get; set; } = null;
|
||||
|
||||
/// <summary> Gets or sets the time, in milliseconds, to wait for a connection to complete before aborting. </summary>
|
||||
public int ConnectionTimeout { get; set; } = 30000;
|
||||
|
||||
@@ -38,41 +40,8 @@ namespace Discord.WebSocket
|
||||
|
||||
public DiscordSocketConfig()
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
WebSocketProvider = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DefaultWebSocketClient();
|
||||
}
|
||||
catch (PlatformNotSupportedException ex)
|
||||
{
|
||||
throw new PlatformNotSupportedException("The default websocket provider is not supported on this platform.", ex);
|
||||
}
|
||||
};
|
||||
UdpSocketProvider = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DefaultUdpSocket();
|
||||
}
|
||||
catch (PlatformNotSupportedException ex)
|
||||
{
|
||||
throw new PlatformNotSupportedException("The default UDP provider is not supported on this platform.", ex);
|
||||
}
|
||||
};
|
||||
#else
|
||||
WebSocketProvider = () =>
|
||||
{
|
||||
throw new PlatformNotSupportedException("The default websocket provider is not supported on this platform.\n" +
|
||||
"You must specify a WebSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
|
||||
};
|
||||
UdpSocketProvider = () =>
|
||||
{
|
||||
throw new PlatformNotSupportedException("The default UDP provider is not supported on this platform.\n" +
|
||||
"You must specify a UdpSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+.");
|
||||
};
|
||||
#endif
|
||||
WebSocketProvider = DefaultWebSocketProvider.Instance;
|
||||
UdpSocketProvider = DefaultUdpSocketProvider.Instance;
|
||||
}
|
||||
|
||||
internal DiscordSocketConfig Clone() => MemberwiseClone() as DiscordSocketConfig;
|
||||
|
||||
Reference in New Issue
Block a user