Commit e66d91d6 authored by Robert Rudman's avatar Robert Rudman

Emit a fake event when successfully connecting. Allow authentication by cookie

parent ff65d8e8
Pipeline #40818134 passed with stages
in 4 minutes and 32 seconds
......@@ -85,6 +85,16 @@ namespace StackExchangeChat
webSocket.Connect();
observer.OnNext(new ChatEvent
{
ChatEventDetails = new ChatEventDetails
{
ChatEventType = ChatEventType.ChatJoined,
RoomId = roomId,
},
RoomDetails = roomDetails
});
return Disposable.Create(() =>
{
webSocket.Close();
......
......@@ -3,8 +3,7 @@
public class ChatCredentials : IChatCredentials
{
public string AcctCookie { get; set; }
public string AcctCookieExpiry { get; set; }
public string Email { get; set; }
public string Password { get; set; }
}
......
......@@ -3,6 +3,11 @@
// Copy & pasted from https://github.com/SOBotics/SharpExchange/blob/master/SharpExchange/Chat/Events/EventType.cs
public enum ChatEventType
{
/// <summary>
/// Custom event type, emitted when successfully joined the room
/// </summary>
ChatJoined = -10,
/// <summary>
/// A new message has been posted.
/// </summary>
......
......@@ -3,8 +3,7 @@
public interface IChatCredentials
{
string AcctCookie { get; set; }
string AcctCookieExpiry { get; set; }
string Email { get; set; }
string Password { get; set; }
}
......
......@@ -108,6 +108,9 @@ namespace StackExchangeChat
async Task<Cookie> GetAccountCookieInternal()
{
if (!string.IsNullOrWhiteSpace(_chatCredentials.AcctCookie))
return new Cookie("acct", _chatCredentials.AcctCookie, "/", chatSite.LoginDomain);
var cookieContainer = new CookieContainer();
using (var httpClient = _serviceProvider.GetService<HttpClientWithHandler>())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment