This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da5d56e
commit 9f017ea
Showing
14 changed files
with
148 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
src/FaluCli/Client/Realtime/RealtimeConnectionNegotiation.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/FaluCli/Client/Realtime/RealtimeConnectionNegotiationRequest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System.Net; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Falu.Client.Realtime; | ||
|
||
public class RealtimeNegotiation | ||
{ | ||
[JsonPropertyName("url")] | ||
public Uri Url { get; set; } = default!; | ||
|
||
[JsonPropertyName("expires")] | ||
public DateTimeOffset Expires { get; set; } | ||
|
||
[JsonPropertyName("token")] | ||
public string Token { get; set; } = default!; | ||
|
||
[JsonPropertyName("state")] | ||
public string State { get; set; } = default!; | ||
|
||
[JsonPropertyName("workspace")] | ||
public string Workspace { get; set; } = default!; | ||
|
||
[JsonPropertyName("live")] | ||
public bool Live { get; set; } | ||
|
||
public CancellationTokenSource MakeCancellationTokenSource(CancellationToken other) | ||
{ | ||
// create a CancellationToken sourced from the other and cancels when the token expires | ||
var lifetime = Expires - DateTimeOffset.UtcNow - TimeSpan.FromSeconds(2); | ||
var cts = CancellationTokenSource.CreateLinkedTokenSource(other); | ||
cts.CancelAfter(lifetime); | ||
return cts; | ||
} | ||
} | ||
|
||
public abstract class RealtimeNegotiationOptions<TFilters> | ||
{ | ||
[JsonPropertyName("ttl")] | ||
public string Ttl { get; set; } = "PT1H"; | ||
|
||
[JsonPropertyName("filters")] | ||
public TFilters? Filters { get; set; } | ||
} | ||
|
||
public class RealtimeNegotiationFiltersRequestLogs | ||
{ | ||
[JsonPropertyName("ip_networks")] | ||
public IPNetwork[]? IPNetworks { get; set; } | ||
|
||
[JsonPropertyName("ip_addresses")] | ||
public IPAddress[]? IPAddresses { get; set; } | ||
|
||
[JsonPropertyName("sources")] | ||
public string[]? Sources { get; set; } | ||
|
||
[JsonPropertyName("paths")] | ||
public string[]? Paths { get; set; } | ||
|
||
[JsonPropertyName("methods")] | ||
public string[]? Methods { get; set; } | ||
|
||
[JsonPropertyName("status_codes")] | ||
public int[]? StatusCodes { get; set; } | ||
} | ||
|
||
public class RealtimeNegotiationFiltersEvents | ||
{ | ||
[JsonPropertyName("types")] | ||
public string[]? Types { get; set; } | ||
} | ||
|
||
public class RealtimeNegotiationOptionsEvents | ||
: RealtimeNegotiationOptions<RealtimeNegotiationFiltersEvents> | ||
{ } | ||
|
||
public class RealtimeNegotiationOptionsRequestLogs | ||
: RealtimeNegotiationOptions<RealtimeNegotiationFiltersRequestLogs> | ||
{ } | ||
|
||
internal class RealtimeMessage | ||
{ | ||
[JsonPropertyName("type")] | ||
public string? Type { get; set; } | ||
|
||
[JsonPropertyName("object")] | ||
public JsonObject? Object { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.