Header menu logo Xanthos

JvLinkService Type

High-level service for interacting with JV-Link COM API.

Thread Safety: This class is NOT thread-safe and enforces single-operation access at runtime using a reentrancy guard. Concurrent calls to long-running methods (FetchPayloads, FetchPayloadsWithBytes, StreamRealtimePayloads) will fail immediately with an InvalidState error rather than causing undefined behavior.

If you need to use JvLinkService in a multi-threaded environment (e.g., ASP.NET Core with concurrent HTTP requests), either:

  • Create a separate JvLinkService instance per request (scoped lifetime)
  • Use a dedicated background service with a queue for JV-Link operations

Constructors

Constructor Description

JvLinkService(client, config, ?logger, ?waitScheduler, ?pollingPolicy, ?retryConfig, ?eventQueueCapacity)

Full Usage: JvLinkService(client, config, ?logger, ?waitScheduler, ?pollingPolicy, ?retryConfig, ?eventQueueCapacity)

Parameters:
Returns: JvLinkService
client : IJvLinkClient
config : JvLinkConfig
?logger : TraceLogger
?waitScheduler : IWaitScheduler
?pollingPolicy : PollingPolicy
?retryConfig : ComRetryConfig
?eventQueueCapacity : int
Returns: JvLinkService

Instance members

Instance member Description

this.CancelDownload

Full Usage: this.CancelDownload

Returns: Result<unit, XanthosError>

Requests JV-Link to cancel the active download thread. Note: This requires an active JVOpen/JVRTOpen session - do not re-initialize.

Returns: Result<unit, XanthosError>

this.CheckMovieAvailability

Full Usage: this.CheckMovieAvailability

Parameters:
Returns: Result<MovieAvailability, XanthosError>

Checks whether a movie is available for the specified movietype via `JVMVCheckWithType`.

movieType : MovieType
key : string
Returns: Result<MovieAvailability, XanthosError>

this.CheckMovieAvailability

Full Usage: this.CheckMovieAvailability

Parameters:
    key : string

Returns: Result<MovieAvailability, XanthosError>

Checks whether a race movie is currently available via `JVMVCheck`.

key : string
Returns: Result<MovieAvailability, XanthosError>

this.DeleteFile

Full Usage: this.DeleteFile

Parameters:
    filename : string

Returns: Result<unit, XanthosError>

Deletes a previously downloaded file from the JV-Link save path.

The filename is passed directly to JVFiledelete without text normalization to preserve full-width characters that may be present in valid file paths.

filename : string
Returns: Result<unit, XanthosError>

this.Dispose

Full Usage: this.Dispose

Releases all resources used by the JvLinkService.

this.FetchPayloads

Full Usage: this.FetchPayloads

Parameters:
Returns: Result<JvPayload list, XanthosError>
spec : string
fromTime : DateTime option
?openOption : int
?cancellationToken : CancellationToken
Returns: Result<JvPayload list, XanthosError>

this.FetchPayloads

Full Usage: this.FetchPayloads

Parameters:
Returns: Result<JvPayload list, XanthosError>

Fetches all available payloads for the specified request, returning them as a materialised list.

request : JvOpenRequest
?cancellationToken : CancellationToken
Returns: Result<JvPayload list, XanthosError>

this.FetchPayloadsWithBytes

Full Usage: this.FetchPayloadsWithBytes

Parameters:
Returns: Result<(JvPayload list * int64), XanthosError>
spec : string
fromTime : DateTime option
?openOption : int
?cancellationToken : CancellationToken
Returns: Result<(JvPayload list * int64), XanthosError>

this.FetchPayloadsWithBytes

Full Usage: this.FetchPayloadsWithBytes

Parameters:
Returns: Result<(JvPayload list * int64), XanthosError>

Fetches payloads along with the total byte count transferred during the request.

request : JvOpenRequest
?cancellationToken : CancellationToken
Returns: Result<(JvPayload list * int64), XanthosError>

this.FetchPayloadsWithSize

Full Usage: this.FetchPayloadsWithSize

Parameters:
Returns: Result<(JvPayload list * int64), XanthosError>
spec : string
fromTime : DateTime option
?openOption : int
?cancellationToken : CancellationToken
Returns: Result<(JvPayload list * int64), XanthosError>

this.FetchPayloadsWithSize

Full Usage: this.FetchPayloadsWithSize

Parameters:
Returns: Result<(JvPayload list * int64), XanthosError>
request : JvOpenRequest
?cancellationToken : CancellationToken
Returns: Result<(JvPayload list * int64), XanthosError>

this.FetchTypedRecords

Full Usage: this.FetchTypedRecords

Parameters:
    spec : string - The dataspec string (e.g., "RACE" for race data).
    fromTime : DateTime option - Start time for data retrieval (required by JVOpen).
    ?openOption : int - Optional open option (default: 1 for standard, 2 for setup without dialog).
    ?cancellationToken : CancellationToken - Optional cancellation token.

Returns: Result<ParsedRecord list, XanthosError>

Fetches payloads and parses them into strongly typed domain records.

spec : string

The dataspec string (e.g., "RACE" for race data).

fromTime : DateTime option

Start time for data retrieval (required by JVOpen).

?openOption : int

Optional open option (default: 1 for standard, 2 for setup without dialog).

?cancellationToken : CancellationToken

Optional cancellation token.

Returns: Result<ParsedRecord list, XanthosError>

this.FetchTypedRecords

Full Usage: this.FetchTypedRecords

Parameters:
    request : JvOpenRequest - The JV-Link open request specifying dataspec and time range.
    ?cancellationToken : CancellationToken - Optional cancellation token.

Returns: Result<ParsedRecord list, XanthosError> A list of parsed records or the first error encountered.

Fetches payloads and parses them into strongly typed domain records. Fails fast on the first parse error.

request : JvOpenRequest

The JV-Link open request specifying dataspec and time range.

?cancellationToken : CancellationToken

Optional cancellation token.

Returns: Result<ParsedRecord list, XanthosError>

A list of parsed records or the first error encountered.

this.FetchTypedRecordsCollectErrors

Full Usage: this.FetchTypedRecordsCollectErrors

Parameters:
    request : JvOpenRequest - The JV-Link open request specifying dataspec and time range.
    ?cancellationToken : CancellationToken - Optional cancellation token.

Returns: Result<(ParsedRecord list * (JvPayload * XanthosError) list), XanthosError> A tuple of successfully parsed records and failed payloads with their errors.

Fetches payloads and parses them, collecting both successes and failures.

request : JvOpenRequest

The JV-Link open request specifying dataspec and time range.

?cancellationToken : CancellationToken

Optional cancellation token.

Returns: Result<(ParsedRecord list * (JvPayload * XanthosError) list), XanthosError>

A tuple of successfully parsed records and failed payloads with their errors.

this.FetchWorkoutVideos

Full Usage: this.FetchWorkoutVideos

Parameters:
Returns: Result<WorkoutVideoListing list, XanthosError>

Fetches workout video listings via `JVMVOpen`/`JVMVRead` for the specified movietype.

movieType : MovieType
searchKey : string
Returns: Result<WorkoutVideoListing list, XanthosError>

this.GenerateSilksFile

Full Usage: this.GenerateSilksFile

Parameters:
    pattern : string
    outputPath : string

Returns: Result<SilksImage, XanthosError>

Generates a silks (勝負服) bitmap on disk using JVFukuFile and returns its location.

This utility function does not open a JV-Link session (JVOpen/JVRTOpen), so it does not close any session. It can be safely used while other sessions are active.

pattern : string
outputPath : string
Returns: Result<SilksImage, XanthosError>

this.GetCourseDiagram

Full Usage: this.GetCourseDiagram

Parameters:
    key : string

Returns: Result<CourseDiagram, XanthosError>

Retrieves a course diagram (file path + explanation) using `JVCourseFile`.

This utility function does not open a JV-Link session (JVOpen/JVRTOpen), so it does not close any session. It can be safely used while other sessions are active.

key : string
Returns: Result<CourseDiagram, XanthosError>

this.GetCourseDiagramBasic

Full Usage: this.GetCourseDiagramBasic

Parameters:
    key : string
    filepath : string

Returns: Result<CourseDiagram, XanthosError>

Saves a course diagram to the specified filepath using `JVCourseFile2`.

This utility function does not open a JV-Link session (JVOpen/JVRTOpen), so it does not close any session. It can be safely used while other sessions are active. The filepath must be a full path to a file in an existing directory.

key : string
filepath : string
Returns: Result<CourseDiagram, XanthosError>

this.GetCurrentFileTimestamp

Full Usage: this.GetCurrentFileTimestamp

Returns: Result<DateTime option, XanthosError>

Returns the timestamp of the file currently being read, if reported by JV-Link.

Returns: Result<DateTime option, XanthosError>

this.GetCurrentReadFileSize

Full Usage: this.GetCurrentReadFileSize

Returns: Result<int64, XanthosError>

Returns the size of the currently read file as reported by JV-Link.

Returns: Result<int64, XanthosError>

this.GetJVLinkVersion

Full Usage: this.GetJVLinkVersion

Returns: Result<string, XanthosError>

Retrieves the JV-Link version string reported by the COM layer.

Returns: Result<string, XanthosError>

this.GetParentWindowHandle

Full Usage: this.GetParentWindowHandle

Returns: Result<IntPtr, XanthosError>

Retrieves the parent window handle configured for JV-Link dialogs.

Returns: Result<IntPtr, XanthosError>

this.GetPayoffDialogSuppressed

Full Usage: this.GetPayoffDialogSuppressed

Returns: Result<bool, XanthosError>

Returns whether payoff dialogs are suppressed within JV-Link.

Returns: Result<bool, XanthosError>

this.GetSaveDownloadsEnabled

Full Usage: this.GetSaveDownloadsEnabled

Returns: Result<bool, XanthosError> Ok(bool) on success, or Error if the property cannot be read.

Returns whether JV-Link is configured to persist downloads to disk.

Returns: Result<bool, XanthosError>

Ok(bool) on success, or Error if the property cannot be read.

this.GetSavePath

Full Usage: this.GetSavePath

Returns: Result<string, XanthosError> Ok(string) on success, or Error if the property cannot be read.

Retrieves the configured JV-Link save path.

Returns: Result<string, XanthosError>

Ok(string) on success, or Error if the property cannot be read.

this.GetServiceKey

Full Usage: this.GetServiceKey

Returns: Result<string, XanthosError> Ok(string) on success, or Error if the property cannot be read.

Gets the JV-Link service key currently configured.

Returns: Result<string, XanthosError>

Ok(string) on success, or Error if the property cannot be read.

this.GetSilksBinary

Full Usage: this.GetSilksBinary

Parameters:
    pattern : string

Returns: Result<SilksImage, XanthosError>

Retrieves a silks (勝負服) bitmap as binary data using JVFuku.

This utility function does not open a JV-Link session (JVOpen/JVRTOpen), so it does not close any session. It can be safely used while other sessions are active.

pattern : string
Returns: Result<SilksImage, XanthosError>

this.GetStatus

Full Usage: this.GetStatus

Returns: Result<int, XanthosError>

Retrieves the number of files whose download has completed for the current session. Note: This requires an active JVOpen/JVRTOpen session - do not re-initialize.

Returns: Result<int, XanthosError>

this.GetTotalReadFileSize

Full Usage: this.GetTotalReadFileSize

Returns: Result<int64, XanthosError>

Returns the total remaining download size in KB (kilobytes) as reported by JV-Link.

JV-Link returns m_TotalReadFilesize in KB. Use GetTotalReadFileSizeBytes for bytes.

Returns: Result<int64, XanthosError>

this.GetTotalReadFileSizeBytes

Full Usage: this.GetTotalReadFileSizeBytes

Returns: Result<int64, XanthosError>

Returns the total remaining download size in bytes.

Converts JV-Link's m_TotalReadFilesize (KB) to bytes by multiplying by 1024.

Returns: Result<int64, XanthosError>

this.PlayMovie

Full Usage: this.PlayMovie

Parameters:
Returns: Result<unit, XanthosError>

Requests movie playback for a specified movietype via `JVMVPlayWithType`.

movieType : MovieType
key : string
Returns: Result<unit, XanthosError>

this.PlayMovie

Full Usage: this.PlayMovie

Parameters:
    key : string

Returns: Result<unit, XanthosError>

Requests movie playback via `JVMVPlay`.

key : string
Returns: Result<unit, XanthosError>

this.SetParentWindowHandle

Full Usage: this.SetParentWindowHandle

Parameters:
Returns: Result<unit, XanthosError>

Sets the parent window handle used for JV-Link dialogs.

handle : IntPtr
Returns: Result<unit, XanthosError>

this.SetPayoffDialogSuppressed

Full Usage: this.SetPayoffDialogSuppressed

Parameters:
    suppressed : bool

Returns: Result<unit, XanthosError>

Configures payoff dialog suppression within JV-Link.

suppressed : bool
Returns: Result<unit, XanthosError>

this.SetSaveDownloadsEnabled

Full Usage: this.SetSaveDownloadsEnabled

Parameters:
    enabled : bool

Returns: Result<unit, XanthosError>

Updates the JV-Link save flag (persist downloads to disk).

enabled : bool
Returns: Result<unit, XanthosError>

this.SetSavePath

Full Usage: this.SetSavePath

Parameters:
    path : string

Returns: Result<unit, XanthosError>

Sets the JV-Link save path.

path : string
Returns: Result<unit, XanthosError>

this.SetServiceKey

Full Usage: this.SetServiceKey

Parameters:
    key : string

Returns: Result<unit, XanthosError>

Sets the JV-Link service key.

key : string
Returns: Result<unit, XanthosError>

this.ShowConfigurationDialog

Full Usage: this.ShowConfigurationDialog

Returns: Result<unit, XanthosError>

Displays the JV-Link configuration dialog via `JVSetUIProperties`.

Returns: Result<unit, XanthosError>

this.SkipCurrentFile

Full Usage: this.SkipCurrentFile

Returns: Result<unit, XanthosError>

Skips the current download file and advances the JV-Link cursor. Note: This requires an active JVOpen/JVRTOpen session - do not re-initialize.

Returns: Result<unit, XanthosError>

this.StartWatchEvents

Full Usage: this.StartWatchEvents

Returns: Result<unit, XanthosError>

Starts JV-Link watch event notifications.

Events are queued to a dedicated background thread to avoid blocking the COM STA thread while preserving FIFO event order. Subscribers should still be lightweight; for heavy processing, offload to a Task or use Reactive Extensions operators like ObserveOn.

If events arrive faster than the subscriber can process them and the queue fills up, incoming events are dropped and an EventQueueOverflow error is emitted on the WatchEvents stream. The queue capacity can be configured via the eventQueueCapacity constructor parameter (default: 10,000).

Returns: Result<unit, XanthosError>

this.StopWatchEvents

Full Usage: this.StopWatchEvents

Returns: Result<unit, XanthosError>

Stops JV-Link watch event notifications.

Returns: Result<unit, XanthosError>

this.StreamPayloads

Full Usage: this.StreamPayloads

Parameters:
    spec : string
    fromTime : DateTime option
    ?openOption : int

Returns: Result<JvPayload, XanthosError> seq

Lazily streams payloads from a JV-Link session (`JVOpen`) until EndOfStream.

spec : string
fromTime : DateTime option
?openOption : int
Returns: Result<JvPayload, XanthosError> seq

this.StreamPayloads

Full Usage: this.StreamPayloads

Parameters:
    request : JvOpenRequest - The JV-Link open request specifying dataspec and time range.

Returns: Result<JvPayload, XanthosError> seq

Lazily streams payloads from a JV-Link session (`JVOpen`) until EndOfStream.

Unlike FetchPayloads, this method yields payloads one at a time without accumulating them in memory. Use this for large data requests where memory is a concern.

Each element in the sequence is a Result<JvPayload, XanthosError>. Callers should check each result and may choose to stop enumeration early on errors.

request : JvOpenRequest

The JV-Link open request specifying dataspec and time range.

Returns: Result<JvPayload, XanthosError> seq

this.StreamPayloadsAsync

Full Usage: this.StreamPayloadsAsync

Parameters:
Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

Asynchronously streams payloads from a JV-Link session (`JVOpen`), with cancellation support.

spec : string
fromTime : DateTime option
?openOption : int
?pollInterval : TimeSpan
?cancellationToken : CancellationToken
Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

this.StreamPayloadsAsync

Full Usage: this.StreamPayloadsAsync

Parameters:
    request : JvOpenRequest - The JV-Link open request specifying dataspec and time range.
    ?pollInterval : TimeSpan - Interval between polls when waiting for downloads (default: 500ms)
    ?cancellationToken : CancellationToken - Token to request cancellation of the stream

Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

Asynchronously streams payloads from a JV-Link session (`JVOpen`), with cancellation support.

Unlike FetchPayloads, this method yields payloads one at a time without accumulating them in memory. Use this for large data requests where memory is a concern.

Cancellation behavior: The cancellation token is checked between COM operations and affects polling delays. However, individual COM calls (JVRead, etc.) cannot be interrupted mid-execution due to COM threading constraints.

request : JvOpenRequest

The JV-Link open request specifying dataspec and time range.

?pollInterval : TimeSpan

Interval between polls when waiting for downloads (default: 500ms)

?cancellationToken : CancellationToken

Token to request cancellation of the stream

Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

this.StreamRealtimeAsync

Full Usage: this.StreamRealtimeAsync

Parameters:
    spec : string - Data spec ID (4 characters, e.g., "0B12", "0B11", "0B16")
    key : string - Request key: "YYYYMMDDJJKKHHRR" (race), "YYYYMMDD" (daily), or WatchEvent parameter
    ?pollInterval : TimeSpan - Interval between polls when no data is available (default: 100ms)
    ?cancellationToken : CancellationToken - Token to request cancellation of the stream

Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

Asynchronously streams payloads from a real-time session (`JVRTOpen`), polling until cancelled.

Cancellation behavior: The cancellation token is checked between COM operations and affects polling delays. However, individual COM calls (JVRead, etc.) cannot be interrupted mid-execution due to COM threading constraints. If a COM call is in progress when cancellation is requested, the operation will complete (or timeout) before the cancellation takes effect. This ensures COM resources remain in a consistent state.

For immediate responsiveness to cancellation, consider using shorter poll intervals. The service's internal timeout (configured via retry policy) provides an upper bound on how long a hung COM call can block before the service becomes poisoned.

spec : string

Data spec ID (4 characters, e.g., "0B12", "0B11", "0B16")

key : string

Request key: "YYYYMMDDJJKKHHRR" (race), "YYYYMMDD" (daily), or WatchEvent parameter

?pollInterval : TimeSpan

Interval between polls when no data is available (default: 100ms)

?cancellationToken : CancellationToken

Token to request cancellation of the stream

Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

this.StreamRealtimePayloads

Full Usage: this.StreamRealtimePayloads

Parameters:
    spec : string - Data spec ID (4 characters, e.g., "0B12", "0B11", "0B16")
    key : string - Request key: "YYYYMMDDJJKKHHRR" (race), "YYYYMMDD" (daily), or WatchEvent parameter

Returns: Result<JvPayload, XanthosError> seq

Lazily streams payloads from a real-time session (`JVRTOpen`) until EndOfStream. For continuous polling, use `StreamRealtimeAsync` which polls until cancelled.

spec : string

Data spec ID (4 characters, e.g., "0B12", "0B11", "0B16")

key : string

Request key: "YYYYMMDDJJKKHHRR" (race), "YYYYMMDD" (daily), or WatchEvent parameter

Returns: Result<JvPayload, XanthosError> seq

this.StreamRealtimePayloadsAsync

Full Usage: this.StreamRealtimePayloadsAsync

Parameters:
Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

Backwards-compatible alias for StreamRealtimeAsync.

spec : string
key : string
?pollInterval : TimeSpan
?cancellationToken : CancellationToken
Returns: IAsyncEnumerable<Result<JvPayload, XanthosError>>

this.WatchEvents

Full Usage: this.WatchEvents

Returns: IObservable<Result<WatchEvent, XanthosError>>

Observable sequence of watch events (`JVWatchEvent` callbacks).

Events are delivered as Result<WatchEvent, XanthosError>. Normally, subscribers receive Ok(event) values. If the internal event queue reaches capacity (due to slow consumer processing), the stream emits Error(EventQueueOverflow n) to notify subscribers of potential event loss. This allows subscribers to detect backpressure.

The queue capacity defaults to 10,000 events and can be configured via the eventQueueCapacity constructor parameter.

Returns: IObservable<Result<WatchEvent, XanthosError>>

Static members

Static member Description

JvLinkService.ClearDiagnosticsSink()

Full Usage: JvLinkService.ClearDiagnosticsSink()

Clears the COM diagnostic sink so traces fall back to stdout.

JvLinkService.ConfigureDiagnosticsSink(sink)

Full Usage: JvLinkService.ConfigureDiagnosticsSink(sink)

Parameters:
    sink : string -> unit

Routes low-level COM diagnostics (emitted by ComJvLinkClient) to the supplied sink.

sink : string -> unit

JvLinkService.GetRecordTypeId(data)

Full Usage: JvLinkService.GetRecordTypeId(data)

Parameters:
    data : byte[] - Raw payload bytes.

Returns: string The record type identifier (e.g., "TK", "RA", "SE").

Extracts the 2-character record type identifier from payload data.

data : byte[]

Raw payload bytes.

Returns: string

The record type identifier (e.g., "TK", "RA", "SE").

JvLinkService.IsComAvailable()

Full Usage: JvLinkService.IsComAvailable()

Returns: bool

Performs a lightweight COM activation check to confirm whether JV-Link is available on the current host.

Returns: bool

JvLinkService.ParsePayload(payload)

Full Usage: JvLinkService.ParsePayload(payload)

Parameters:
    payload : JvPayload - The payload to parse.

Returns: Result<ParsedRecord, XanthosError> The parsed record or an error.

Parses a single JV payload into a typed domain record.

payload : JvPayload

The payload to parse.

Returns: Result<ParsedRecord, XanthosError>

The parsed record or an error.

JvLinkService.ParsePayloads(payloads)

Full Usage: JvLinkService.ParsePayloads(payloads)

Parameters:
    payloads : JvPayload list - The payloads to parse.

Returns: Result<ParsedRecord list, XanthosError> The list of parsed records or the first error encountered.

Parses multiple JV payloads into typed domain records.

payloads : JvPayload list

The payloads to parse.

Returns: Result<ParsedRecord list, XanthosError>

The list of parsed records or the first error encountered.

JvLinkService.TryParsePayloads(payloads)

Full Usage: JvLinkService.TryParsePayloads(payloads)

Parameters:
    payloads : JvPayload list - The payloads to parse.

Returns: ParsedRecord list * (JvPayload * XanthosError) list A tuple of successfully parsed records and failed payloads with their errors.

Parses multiple JV payloads, collecting both successes and failures.

payloads : JvPayload list

The payloads to parse.

Returns: ParsedRecord list * (JvPayload * XanthosError) list

A tuple of successfully parsed records and failed payloads with their errors.

Type something to start searching.