<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Mpd__Client_lwt (libmpdclient.Mpd__Client_lwt)</title><link rel="stylesheet" href="../odoc.css"/><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../index.html">libmpdclient</a> &#x00BB; Mpd__Client_lwt</nav><h1>Module <code>Mpd__Client_lwt</code></h1><p>Provides functions and type in order to communicate to the mpd server with commands and requests in Lwt threads.</p></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type </span>t</code></dt><dd><p>Type for a Mpd Client to be used with Lwt promises.</p></dd></dl><dl><dt class="spec value" id="val-initialize"><a href="#val-initialize" class="anchor"></a><code><span class="keyword">val </span>initialize : <a href="../Mpd/Connection_lwt/index.html#type-t">Mpd.Connection_lwt.t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> Lwt.t</code></dt><dd><p>Initialize the client with a connection.</p></dd></dl><dl><dt class="spec value" id="val-mpd_banner"><a href="#val-mpd_banner" class="anchor"></a><code><span class="keyword">val </span>mpd_banner : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string Lwt.t</code></dt><dd><p>Return the mpd banner that the server send at the first connection of the client.</p></dd></dl><dl><dt class="spec value" id="val-idle"><a href="#val-idle" class="anchor"></a><code><span class="keyword">val </span>idle : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> (string, string) Stdlib.Pervasives.result Lwt.t</code></dt><dd><p>Wait for an event to occur in order to return. When a Client send this * command to the Mpd server throught its connection, the Mpd server do * not answer to any other command except the noidle command. The idea is * to first cancel the promise that has send the &quot;idle&quot; command with * Lwt.cancel and then send the noidle command to the Mpd server. An * example can be found in samples/mpd_lwt_client_idle_noidle.ml.</p></dd></dl><dl><dt class="spec value" id="val-idle_loop"><a href="#val-idle_loop" class="anchor"></a><code><span class="keyword">val </span>idle_loop : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> (string <span>&#45;&gt;</span> bool Lwt.t) <span>&#45;&gt;</span> unit Lwt.t</code></dt><dd><p>Loop on mpd event with the &quot;idle&quot; command the on_event function take the event response as argument and return true to stop or false to continue the loop</p></dd></dl><dl><dt class="spec value" id="val-send"><a href="#val-send" class="anchor"></a><code><span class="keyword">val </span>send : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string <span>&#45;&gt;</span> <a href="../Mpd/Protocol/index.html#type-response">Mpd.Protocol.response</a> Lwt.t</code></dt><dd><p>Send to the mpd server a command. The response of the server is returned under the form of a Protocol.response type.</p></dd></dl><dl><dt class="spec value" id="val-request"><a href="#val-request" class="anchor"></a><code><span class="keyword">val </span>request : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string <span>&#45;&gt;</span> <a href="../Mpd/Protocol/index.html#type-response">Mpd.Protocol.response</a> Lwt.t</code></dt><dd><p>Send to the mpd server a request. The response of the server is returned under the form of a Protocol.response type. A request is different from a command because a command generate an action from Mpd and returns &quot;OK&quot; or an error while a request does not generate an action from Mpd and returns &quot;some data to analyse&quot;OK or an error.</p></dd></dl><dl><dt class="spec value" id="val-status"><a href="#val-status" class="anchor"></a><code><span class="keyword">val </span>status : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> (<a href="../Mpd/Status/index.html#type-t">Mpd.Status.t</a>, string) Stdlib.Pervasives.result Lwt.t</code></dt><dd><p>Create a status request and returns the status under a Mpd.Status.s Lwt.t type.</p></dd></dl><dl><dt class="spec value" id="val-ping"><a href="#val-ping" class="anchor"></a><code><span class="keyword">val </span>ping : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="../Mpd/Protocol/index.html#type-response">Mpd.Protocol.response</a> Lwt.t</code></dt><dd><p>Does nothing but return &quot;OK&quot;.</p></dd></dl><dl><dt class="spec value" id="val-password"><a href="#val-password" class="anchor"></a><code><span class="keyword">val </span>password : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string <span>&#45;&gt;</span> <a href="../Mpd/Protocol/index.html#type-response">Mpd.Protocol.response</a> Lwt.t</code></dt><dd><p>This is used for authentication with the server. PASSWORD is simply the plaintext password.</p></dd></dl><dl><dt class="spec value" id="val-noidle"><a href="#val-noidle" class="anchor"></a><code><span class="keyword">val </span>noidle : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="../Mpd/Protocol/index.html#type-response">Mpd.Protocol.response</a> Lwt.t</code></dt><dd><p>This command is needed to stop listening after a Client.idle command. An example of usage can be seen in samples/mpd_lwt_client_idle_noidle.exe.</p></dd></dl><dl><dt class="spec value" id="val-close"><a href="#val-close" class="anchor"></a><code><span class="keyword">val </span>close : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit Lwt.t</code></dt><dd><p>Close the client. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the &quot;close&quot; command of the Mpd protocol, this means that it first send the &quot;close&quot; command and it close the connection at the socket level.</p></dd></dl></div></body></html>