Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.43 KB

File metadata and controls

48 lines (37 loc) · 1.43 KB

CarpaNet.Jetstream

NuGet Version License

CarpaNet Logo

CarpaNet.Jetstream lets you connect to a Bluesky Jetstream instance.

1444070256569233

This library is experimental and not stable. Expect issues and bugs!

How to use

byte[]? zstdDictionary = null;
if (zstdDictionaryPath != null)
{
    zstdDictionary = File.ReadAllBytes(zstdDictionaryPath);
    Console.WriteLine($"Loaded zstd dictionary from {zstdDictionaryPath} ({zstdDictionary.Length} bytes)");
}
else if (compress)
{
    Console.WriteLine("Warning: --compress specified without --zstd-dictionary. Binary frames will fail to decompress.");
}

using var client = new JetstreamClient(new Uri(endpoint), zstdDictionary);

var options = new JetstreamSubscribeOptions
{
    Cursor = cursor,
    WantedCollections = collections.Count > 0 ? collections : null,
    WantedDids = dids.Count > 0 ? dids : null,
    Compress = compress,
};

try
{
    await foreach (var evt in client.SubscribeAsync(options, cts.Token))
    {
        switch (evt.Kind)
        {
            // ... switch on events...
        }
    }
}