OutputChannelHost Class#
The session's IOutputChannelHost. Owned by Scaffold and living as long as it does, which is the whole point: a channel has to still work when no cell is running, because that is when someone is interacting with what the last cell drew.
public sealed class OutputChannelHost : Verso.Abstractions.IOutputChannelHost, System.IAsyncDisposable
Inheritance System.Object → OutputChannelHost
Implements IOutputChannelHost, System.IAsyncDisposable
Fields#
MaxQueuedBytes Field#
The same bound counted in bytes, for a caller sending few large messages.
public const long MaxQueuedBytes = 8388608;
Field Value#
MaxQueuedMessages Field#
Messages held for a view that has not mounted. The number is generous for the case it exists for, an output whose first few messages are produced while the client is still drawing it, and small enough that a caller writing to a view that will never mount is stopped rather than left to grow.
public const int MaxQueuedMessages = 256;
Field Value#
Properties#
CanReachViews Property#
Whether this host has anywhere to send. What decides whether a context reports channels at all: a caller that finds OutputChannels null writes static output, which is the right answer for a host with no view to talk to and a better one than opening a channel that would queue until it failed.
public bool CanReachViews { get; }
Property Value#
Transport Property#
How messages reach a view. Set by the shell that has one; left null by a host that renders to a file or a terminal.
public Verso.Execution.IOutputChannelTransport? Transport { get; set; }
Property Value#
Methods#
CloseAllAsync(string) Method#
Closes every open channel. What a kernel restart or a crash comes to.
public System.Threading.Tasks.Task CloseAllAsync(string reason);
Parameters#
reason System.String
Returns#
CloseAsync(string, string) Method#
Closes one channel and tells its view, if the channel is open.
public System.Threading.Tasks.Task CloseAsync(string channelId, string reason);
Parameters#
channelId System.String
reason System.String
Returns#
CloseForCell(Guid, string) Method#
Closes every channel belonging to one cell without telling the views, for the cases where the output the view was drawing is going away with the channel: the cell is being re-run, its outputs cleared, or the cell itself deleted.
public void CloseForCell(System.Guid cellId, string reason);
Parameters#
cellId System.Guid
reason System.String
Remarks#
Telling a view is what the asynchronous form is for, and it is what a kernel restart needs, because there the view stays on the page and has to learn that it is no longer live. Here there is nobody left to tell, which is also what makes this callable from the ordinary synchronous notebook operations rather than only from something already asynchronous.
CloseForCellAsync(Guid, string) Method#
Closes every channel belonging to one cell. What a cell being re-run, cleared, or deleted comes to.
public System.Threading.Tasks.Task CloseForCellAsync(System.Guid cellId, string reason);
Parameters#
cellId System.Guid
reason System.String
Returns#
Find(string) Method#
Finds an open channel by id, or null if there is none by that id.
public Verso.Abstractions.IOutputChannel? Find(string channelId);
Parameters#
channelId System.String
Implements Find(string)
Returns#
ForCell(Guid) Method#
Every channel currently open for a cell.
public System.Collections.Generic.IReadOnlyList<Verso.Abstractions.IOutputChannel> ForCell(System.Guid cellId);
Parameters#
cellId System.Guid
Implements ForCell(Guid)
Returns#
System.Collections.Generic.IReadOnlyList<IOutputChannel>
HandleMessageAsync(string, string, string, IReadOnlyList<byte[]>) Method#
A message from a view, on its way to the channel's owner. A message naming a channel that is not open is dropped without complaint: the ordinary way to get one is for a view to answer a moment after its channel closed.
public System.Threading.Tasks.Task HandleMessageAsync(string channelId, string messageType, string? payload, System.Collections.Generic.IReadOnlyList<byte[]>? buffers=null);
Parameters#
channelId System.String
messageType System.String
payload System.String
buffers System.Collections.Generic.IReadOnlyList<System.Byte[]>
Returns#
HandleReadyAsync(string, string, CancellationToken) Method#
A view reporting that it has mounted and can receive. Flushes whatever was queued for it, in the order it was posted. A view that unmounts and mounts again reports itself ready again, and a second report on a channel with nothing queued does nothing.
public System.Threading.Tasks.Task HandleReadyAsync(string channelId, string? viewProtocolVersion=null, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters#
channelId System.String
The channel the view claims to be drawing.
viewProtocolVersion System.String
The protocol version the view declares, or null when it declares none. A view whose major version differs from the host's is reported and then mounted regardless, because a view one version out usually still works and refusing it would replace a warning with a blank output.
ct System.Threading.CancellationToken
Cancels the flush.
Returns#
OpenAsync(Guid, CancellationToken) Method#
Opens a channel for an output the caller is about to write. The channel is usable immediately; messages posted before the view mounts and reports itself ready are queued and delivered in order once it does.
public System.Threading.Tasks.Task<Verso.Abstractions.IOutputChannel> OpenAsync(System.Guid cellId, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters#
cellId System.Guid
ct System.Threading.CancellationToken
Implements OpenAsync(Guid, CancellationToken)
Returns#
System.Threading.Tasks.Task<IOutputChannel>
RequestSnapshotAsync(IOutputChannel, CancellationToken) Method#
Asks a channel's owner for a current document for the output it belongs to, giving up when ct is cancelled. Null means there was no provider, it declined, or it did not answer, and in every one of those the content already written is what stands.
public static System.Threading.Tasks.Task<string?> RequestSnapshotAsync(Verso.Abstractions.IOutputChannel channel, System.Threading.CancellationToken ct);
Parameters#
channel IOutputChannel
ct System.Threading.CancellationToken