Class LinksClient
Sends substitution queries to a LiNo server over any ILinoProtocol and any IPC transport.
public sealed class LinksClient : IDisposable
- Inheritance
-
LinksClient
- Implements
- Inherited Members
Remarks
A server pushes the changes a connection subscribed to between its replies; a pushed document starts with
(notify: N). Request(IReadOnlyList<Link<string>>) sets the pushes it meets aside for ReceiveNotification(TimeSpan), so
replies and pushes never get mixed up. The client is not thread safe.
Properties
Kind
The transport kind the client is connected through, such as tcp or unix.
public string Kind { get; }
Property Value
PendingNotifications
The number of pushes received and not yet taken by ReceiveNotification(TimeSpan).
public int PendingNotifications { get; }
Property Value
Protocol
The protocol used for every message.
public ILinoProtocol Protocol { get; }
Property Value
Methods
Authenticate(string)
Sends (auth: token): every later request of the connection runs as the subject the server gives
the token, which this returns (issue #149). A token the server does not know raises a
Remote error.
public uint Authenticate(string token)
Parameters
tokenstring
Returns
Connect(string, ILinoProtocol)
Connects to an address written as host:port.
public static LinksClient Connect(string endPoint, ILinoProtocol protocol)
Parameters
endPointstringprotocolILinoProtocol
Returns
Connect(string, int, ILinoProtocol)
Connects to host:port over TCP using protocol.
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "The created object is owned by the returned stream or listener, and failure paths dispose it.")]
public static LinksClient Connect(string host, int port, ILinoProtocol protocol)
Parameters
hoststringportintprotocolILinoProtocol
Returns
ConnectEndpoint(string, ILinoProtocol)
Connects to an IPC endpoint (see Endpoint), such as 127.0.0.1:8080,
unix:/tmp/links.sock, pipe:links or shm:/tmp/links, using protocol.
public static LinksClient ConnectEndpoint(string endpoint, ILinoProtocol protocol)
Parameters
endpointstringprotocolILinoProtocol
Returns
Exceptions
- LinoProtocolException
The endpoint is not valid or cannot be reached, as an Io error.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FromStream(IpcStream, ILinoProtocol)
Talks to a server through an open IpcStream, which the client then owns.
public static LinksClient FromStream(IpcStream stream, ILinoProtocol protocol)
Parameters
streamIpcStreamprotocolILinoProtocol
Returns
Query(string)
Runs a LiNo substitution query; the empty query reads every link.
public IReadOnlyList<Link<string>> Query(string query)
Parameters
querystring
Returns
- IReadOnlyList<Link<string>>
QueryLossless(string)
Sends original query text to a peer supporting the explicit query envelope. Never retries a mutation through a different representation.
public IReadOnlyList<Link<string>> QueryLossless(string query)
Parameters
querystring
Returns
- IReadOnlyList<Link<string>>
QueryText(string)
Like Query(string), returning the reply as canonical text.
public string QueryText(string query)
Parameters
querystring
Returns
ReceiveNotification(TimeSpan)
The next document the server pushed, (notify: N) and its changes, waiting up to
timeout for one; null when none arrived in time.
public IReadOnlyList<Link<string>>? ReceiveNotification(TimeSpan timeout)
Parameters
timeoutTimeSpan
Returns
- IReadOnlyList<Link<string>>
Exceptions
- LinoProtocolException
The connection closed, or the server sent something other than a push while no request was waiting.
Request(IReadOnlyList<Link<string>>)
Sends a parsed document and returns the reply document. An
(error: 'message') reply raises a Remote error.
public IReadOnlyList<Link<string>> Request(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- IReadOnlyList<Link<string>>