Browse Source

Added token login and missing dependency

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
7ed231a499
2 changed files with 34 additions and 4 deletions
  1. +33
    -4
      src/Discord.Net/DiscordClient.cs
  2. +1
    -0
      src/Discord.Net/project.json

+ 33
- 4
src/Discord.Net/DiscordClient.cs View File

@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;


@@ -381,6 +380,13 @@ namespace Discord
} }
break; break;


//Settings
case "USER_SETTINGS_UPDATE":
{
//TODO: Process this
}
break;

//Others //Others
default: default:
RaiseOnDebugMessage("Unknown WebSocket message type: " + e.Type); RaiseOnDebugMessage("Unknown WebSocket message type: " + e.Type);
@@ -508,7 +514,17 @@ namespace Discord
} }


//Auth //Auth
public async Task Connect(string email, string password)
public async Task<string> Connect(string token)
{
_isStopping.Reset();
Http.Token = token;
await _webSocket.ConnectAsync(Endpoints.WebSocket_Hub, true);

_isReady = true;
return token;
}
public async Task<string> Connect(string email, string password)
{ {
_isStopping.Reset(); _isStopping.Reset();


@@ -522,8 +538,20 @@ namespace Discord
_webSocket.Login(); _webSocket.Login();


_isReady = true; _isReady = true;
}
public async Task ConnectAnonymous(string username)
return response.Token;
}
public async Task<string> Connect(string email, string password, string token)
{
try
{
return await Connect(token);
}
catch (InvalidOperationException) //Bad Token
{
return await Connect(email, password);
}
}
public async Task<string> ConnectAnonymous(string username)
{ {
_isStopping.Reset(); _isStopping.Reset();


@@ -537,6 +565,7 @@ namespace Discord
_webSocket.Login(); _webSocket.Login();


_isReady = true; _isReady = true;
return response.Token;
} }
public async Task Disconnect() public async Task Disconnect()
{ {


+ 1
- 0
src/Discord.Net/project.json View File

@@ -24,6 +24,7 @@
"dnxcore50": { "dnxcore50": {
"dependencies": { "dependencies": {
"System.Collections.Concurrent": "4.0.10", "System.Collections.Concurrent": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.IO.Compression": "4.0.0", "System.IO.Compression": "4.0.0",
"System.Linq": "4.0.0", "System.Linq": "4.0.0",
"System.Net.Requests": "4.0.10", "System.Net.Requests": "4.0.10",


Loading…
Cancel
Save