@@ -12,11 +12,14 @@ | |||||
"compilationOptions": { | "compilationOptions": { | ||||
"warningsAsErrors": true | "warningsAsErrors": true | ||||
}, | }, | ||||
"dependencies": { | "dependencies": { | ||||
"Discord.Net": "0.8.1-beta1" | "Discord.Net": "0.8.1-beta1" | ||||
}, | }, | ||||
"frameworks": { | "frameworks": { | ||||
"net45": { }, | "net45": { }, | ||||
"dnx451": { } | |||||
"dnx451": { }, | |||||
"dnxcore50": { } | |||||
} | } | ||||
} | } |
@@ -12,12 +12,15 @@ | |||||
"compilationOptions": { | "compilationOptions": { | ||||
"warningsAsErrors": true | "warningsAsErrors": true | ||||
}, | }, | ||||
"dependencies": { | "dependencies": { | ||||
"Discord.Net": "0.8.1-beta1", | "Discord.Net": "0.8.1-beta1", | ||||
"Discord.Net.Commands": "0.8.1-beta1" | "Discord.Net.Commands": "0.8.1-beta1" | ||||
}, | }, | ||||
"frameworks": { | "frameworks": { | ||||
"net45": { }, | "net45": { }, | ||||
"dnx451": { } | |||||
"dnx451": { }, | |||||
"dnxcore50": { } | |||||
} | } | ||||
} | } |
@@ -17,8 +17,12 @@ namespace Discord.Net.Rest | |||||
public RestClient(DiscordAPIClientConfig config) | public RestClient(DiscordAPIClientConfig config) | ||||
{ | { | ||||
_config = config; | _config = config; | ||||
#if !DNXCORE50 | |||||
_engine = new SharpRestEngine(config); | _engine = new SharpRestEngine(config); | ||||
} | |||||
#else | |||||
//_engine = new BuiltInRestEngine(config); | |||||
#endif | |||||
} | |||||
public void SetToken(string token) => _engine.SetToken(token); | public void SetToken(string token) => _engine.SetToken(token); | ||||
@@ -1,4 +1,5 @@ | |||||
using Discord.API; | |||||
#if !DNXCORE50 | |||||
using Discord.API; | |||||
using RestSharp; | using RestSharp; | ||||
using System; | using System; | ||||
using System.Net; | using System.Net; | ||||
@@ -82,4 +83,5 @@ namespace Discord.Net.Rest | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -131,8 +131,10 @@ namespace Discord.Net.WebSockets | |||||
} | } | ||||
else //Dont make an OS thread if we only want to capture one packet... | else //Dont make an OS thread if we only want to capture one packet... | ||||
tasks.Add(Task.Run(() => ReceiveVoiceAsync(_cancelToken))); | tasks.Add(Task.Run(() => ReceiveVoiceAsync(_cancelToken))); | ||||
#if !DNXCORE50 | |||||
tasks.Add(WatcherAsync()); | tasks.Add(WatcherAsync()); | ||||
#endif | |||||
if (tasks.Count > 0) | if (tasks.Count > 0) | ||||
{ | { | ||||
// We need to combine tasks into one because receiveThread is | // We need to combine tasks into one because receiveThread is | ||||
@@ -176,6 +178,7 @@ namespace Discord.Net.WebSockets | |||||
private void ReceiveVoiceAsync(CancellationToken cancelToken) | private void ReceiveVoiceAsync(CancellationToken cancelToken) | ||||
{ | { | ||||
var closeTask = cancelToken.Wait(); | |||||
try | try | ||||
{ | { | ||||
byte[] packet, decodingBuffer = null, nonce = null, result; | byte[] packet, decodingBuffer = null, nonce = null, result; | ||||
@@ -193,7 +196,18 @@ namespace Discord.Net.WebSockets | |||||
Thread.Sleep(1); | Thread.Sleep(1); | ||||
if (_udp.Available > 0) | if (_udp.Available > 0) | ||||
{ | { | ||||
#if !DNXCORE50 | |||||
packet = _udp.Receive(ref endpoint); | packet = _udp.Receive(ref endpoint); | ||||
#else | |||||
//TODO: Is this really the only way to end a Receive call in DNXCore? | |||||
var receiveTask = _udp.ReceiveAsync(); | |||||
var task = Task.WhenAny(closeTask, receiveTask).Result; | |||||
if (task == closeTask) | |||||
break; | |||||
var udpPacket = receiveTask.Result; | |||||
packet = udpPacket.Buffer; | |||||
endpoint = udpPacket.RemoteEndPoint; | |||||
#endif | |||||
packetLength = packet.Length; | packetLength = packet.Length; | ||||
if (packetLength > 0 && endpoint.Equals(_endpoint)) | if (packetLength > 0 && endpoint.Equals(_endpoint)) | ||||
@@ -367,6 +381,7 @@ namespace Discord.Net.WebSockets | |||||
catch (OperationCanceledException) { } | catch (OperationCanceledException) { } | ||||
catch (InvalidOperationException) { } //Includes ObjectDisposedException | catch (InvalidOperationException) { } //Includes ObjectDisposedException | ||||
} | } | ||||
#if !DNXCORE50 | |||||
//Closes the UDP socket when _disconnectToken is triggered, since UDPClient doesn't allow passing a canceltoken | //Closes the UDP socket when _disconnectToken is triggered, since UDPClient doesn't allow passing a canceltoken | ||||
private Task WatcherAsync() | private Task WatcherAsync() | ||||
{ | { | ||||
@@ -374,6 +389,7 @@ namespace Discord.Net.WebSockets | |||||
return cancelToken.Wait() | return cancelToken.Wait() | ||||
.ContinueWith(_ => _udp.Close()); | .ContinueWith(_ => _udp.Close()); | ||||
} | } | ||||
#endif | |||||
protected override async Task ProcessMessage(string json) | protected override async Task ProcessMessage(string json) | ||||
{ | { | ||||
@@ -1,4 +1,5 @@ | |||||
using Discord.Helpers; | |||||
#if DNXCORE50zzz | |||||
using Discord.Helpers; | |||||
using System; | using System; | ||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -148,4 +149,5 @@ namespace Discord.Net.WebSockets | |||||
_sendQueue.Enqueue(message); | _sendQueue.Enqueue(message); | ||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -51,8 +51,12 @@ namespace Discord.Net.WebSockets | |||||
_loginTimeout = client.Config.ConnectionTimeout; | _loginTimeout = client.Config.ConnectionTimeout; | ||||
_cancelToken = new CancellationToken(true); | _cancelToken = new CancellationToken(true); | ||||
_connectedEvent = new ManualResetEventSlim(false); | _connectedEvent = new ManualResetEventSlim(false); | ||||
#if !DNXCORE50 | |||||
_engine = new WebSocketSharpEngine(this, client.Config); | _engine = new WebSocketSharpEngine(this, client.Config); | ||||
#else | |||||
//_engine = new BuiltInWebSocketEngine(this, client.Config); | |||||
#endif | |||||
_engine.BinaryMessage += (s, e) => | _engine.BinaryMessage += (s, e) => | ||||
{ | { | ||||
using (var compressed = new MemoryStream(e.Data, 2, e.Data.Length - 2)) | using (var compressed = new MemoryStream(e.Data, 2, e.Data.Length - 2)) | ||||
@@ -1,7 +1,7 @@ | |||||
using System; | |||||
#if !DNXCORE50 | |||||
using System; | |||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Net; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using WSSharpNWebSocket = WebSocketSharp.WebSocket; | using WSSharpNWebSocket = WebSocketSharp.WebSocket; | ||||
@@ -111,4 +111,5 @@ namespace Discord.Net.WebSockets | |||||
_sendQueue.Enqueue(message); | _sendQueue.Enqueue(message); | ||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -17,32 +17,57 @@ | |||||
"compilationOptions": { | "compilationOptions": { | ||||
"allowUnsafe": true | "allowUnsafe": true | ||||
}, | }, | ||||
"configurations": { | |||||
"FullDebug": { | |||||
"compilationOptions": { | |||||
"define": [ | |||||
"DEBUG", | |||||
"TRACE", | |||||
"TEST_RESPONSES" | |||||
] | |||||
} | |||||
} | |||||
}, | |||||
"dependencies": { | |||||
"Newtonsoft.Json": "7.0.1", | |||||
"RestSharp": "105.2.3", | |||||
"WebSocketSharp": "1.0.3-rc9" | |||||
}, | |||||
"configurations": { | |||||
"FullDebug": { | |||||
"compilationOptions": { | |||||
"define": [ | |||||
"DEBUG", | |||||
"TRACE", | |||||
"TEST_RESPONSES" | |||||
] | |||||
} | |||||
} | |||||
}, | |||||
"dependencies": { | |||||
"Newtonsoft.Json": "7.0.1" | |||||
}, | |||||
"frameworks": { | "frameworks": { | ||||
"net45": { | "net45": { | ||||
"frameworkAssemblies": { | "frameworkAssemblies": { | ||||
"System.Net.Http": "4.0.0.0" | "System.Net.Http": "4.0.0.0" | ||||
} | |||||
}, | |||||
"dependencies": { | |||||
"RestSharp": "105.2.3", | |||||
"WebSocketSharp": "1.0.3-rc9" | |||||
} | |||||
}, | }, | ||||
"dnx451": { | "dnx451": { | ||||
"frameworkAssemblies": { | "frameworkAssemblies": { | ||||
"System.Net.Http": "4.0.0.0" | "System.Net.Http": "4.0.0.0" | ||||
} | |||||
} | |||||
}, | |||||
"dependencies": { | |||||
"RestSharp": "105.2.3", | |||||
"WebSocketSharp": "1.0.3-rc9" | |||||
} | |||||
}, | |||||
"dnxcore50": { | |||||
"dependencies": { | |||||
"System.Collections": "4.0.11-beta-23409", | |||||
"System.Collections.Concurrent": "4.0.11-beta-23409", | |||||
"System.IO.Compression": "4.0.1-beta-23409", | |||||
"System.Linq": "4.0.1-beta-23409", | |||||
"System.Net.Http": "4.0.1-beta-23409", | |||||
"System.Net.NameResolution": "4.0.0-beta-23409", | |||||
"System.Net.Sockets": "4.1.0-beta-23409", | |||||
"System.Net.Requests": "4.0.11-beta-23409", | |||||
"System.Net.WebSockets.Client": "4.0.0-beta-23409", | |||||
"System.Runtime.InteropServices": "4.0.21-beta-23409", | |||||
"System.Text.RegularExpressions": "4.0.11-beta-23409", | |||||
"System.Threading": "4.0.11-beta-23409", | |||||
"System.Threading.Thread": "4.0.0-beta-23409" | |||||
} | |||||
} | |||||
} | } | ||||
} | } |