Skip to content

Commit

Permalink
Update options
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions committed Jul 31, 2023
1 parent 1e075dd commit 8913a04
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/FishyFlip/ATProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public ATProtocol(ATProtocolOptions options)
/// </summary>
public bool IsSubscriptionActive => this.webSocketProtocol.IsConnected;

/// <summary>
/// Gets the base address for the underlying HttpClient.
/// </summary>
public Uri? BaseAddress => this.client.BaseAddress;

/// <summary>
/// Gets the Internal HttpClient.
/// </summary>
Expand Down Expand Up @@ -170,7 +175,14 @@ public void UpdateOptions(ATProtocolOptions options)
this.sessionManager.Dispose();
this.webSocketProtocol = new ATWebSocketProtocol(this);
this.webSocketProtocol.OnConnectionUpdated += this.WebSocketProtocolOnConnectionUpdated;
this.sessionManager = new SessionManager(this);
if (options.Session is not null)
{
this.sessionManager = new SessionManager(this, options.Session);
}
else
{
this.sessionManager = new SessionManager(this);
}
}

/// <inheritdoc/>
Expand Down Expand Up @@ -207,7 +219,7 @@ internal void OnUserLoggedIn(Session session)
/// Sets the current session.
/// </summary>
/// <param name="session"><see cref="Session"/>.</param>
public void SetSession(Session session)
internal void SetSession(Session session)
=> this.sessionManager?.SetSession(session);

private void Dispose(bool disposing)
Expand Down
13 changes: 13 additions & 0 deletions src/FishyFlip/ATProtocolBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright (c) Drastic Actions. All rights reserved.
// </copyright>

using System.Security.Cryptography.X509Certificates;

namespace FishyFlip;

/// <summary>
Expand Down Expand Up @@ -96,6 +98,17 @@ public ATProtocolBuilder WithSessionRefreshInterval(TimeSpan interval)
return this;
}

/// <summary>
/// Sets an initial session to use.
/// </summary>
/// <param name="session"><see cref="Session"/>.</param>
/// <returns><see cref="ATProtocolBuilder"/></returns>
public ATProtocolBuilder WithInitialSession(Session session)
{
this.atProtocolOptions.Session = session;
return this;
}

/// <summary>
/// Set the ATProtocol to use admin credentials.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/FishyFlip/ATProtocolOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public ATProtocolOptions()
/// </summary>
public ILogger? Logger { get; internal set; }

/// <summary>
/// Gets the initial session.
/// </summary>
public Session? Session { get; internal set; }

/// <summary>
/// Gets the instance Url.
/// </summary>
Expand Down

0 comments on commit 8913a04

Please sign in to comment.