Skip to content

KgpImageStore

Namespace: Hex1b

Assembly: Hex1b.dll

Central store for KGP images. Manages image IDs, image numbers, chunked transfers, and storage quotas.

csharp
public sealed class KgpImageStore

Inheritance

ObjectKgpImageStore

Constructors

KgpImageStore(long)

Creates a new image store with the specified storage quota.

Parameters:

  • quotaBytes (Int64): Maximum total image data size in bytes. Default: 320MB (matching kitty).
csharp
public KgpImageStore(long quotaBytes = 335544320)

Properties

ImageCount

Number of images currently stored.

Returns: Int32

csharp
public int ImageCount { get; }

IsChunkedTransferInProgress

Whether a chunked transfer is in progress.

Returns: Boolean

csharp
public bool IsChunkedTransferInProgress { get; }

TotalSize

Total size of all stored image data in bytes.

Returns: Int64

csharp
public long TotalSize { get; }

Methods

AbortChunkedTransfer()

Aborts any in-progress chunked transfer.

csharp
public void AbortChunkedTransfer()

AllocateId()

Allocates a unique image ID.

Returns: UInt32

csharp
public uint AllocateId()

Clear()

Removes all images.

csharp
public void Clear()

GetImageById(uint)

Gets an image by its ID.

Parameters:

Returns: KgpImageData

csharp
public KgpImageData? GetImageById(uint imageId)

GetImageByNumber(uint)

Gets the newest image with the specified image number.

Parameters:

Returns: KgpImageData

csharp
public KgpImageData? GetImageByNumber(uint imageNumber)

ProcessChunk(KgpCommand, byte[])

Begins or continues a chunked transfer. Returns the completed image when the final chunk arrives.

Parameters:

  • command (KgpCommand): The KGP command for this chunk.
  • decodedData (Byte[]): The base64-decoded payload data for this chunk.

Returns: KgpImageData

The completed when the final chunk (m=0) is received, or null if more chunks are expected.

csharp
public KgpImageData? ProcessChunk(KgpCommand command, byte[] decodedData)

RemoveImage(uint)

Removes an image by its ID.

Parameters:

Returns: Boolean

True if the image was found and removed.

csharp
public bool RemoveImage(uint imageId)

RemoveImageByNumber(uint)

Removes the newest image with the specified number.

Parameters:

Returns: Boolean

True if an image was found and removed.

csharp
public bool RemoveImageByNumber(uint imageNumber)

StoreImage(KgpImageData)

Stores an image. If an image with the same ID already exists, it is replaced.

Parameters:

Returns: KgpImageData

The stored image, or null if quota would be exceeded and no eviction possible.

csharp
public KgpImageData? StoreImage(KgpImageData image)

Remarks

Thread-safe. All public methods are synchronized.

Released under the MIT License.