{-|
Module      : Network.MPD.Commands.ClientToClient
Copyright   : (c) Joachim Fasting 2013
License     : MIT (see LICENSE)

Maintainer  : joachifm@fastmail.fm
Stability   : stable
Portability : unportable

Client-to-client communication.
-}

module Network.MPD.Commands.ClientToClient
    ( -- * Types
      A.ChannelName
    , A.MessageText
      -- * Subscribing to channels
    , subscribe
    , unsubscribe
    , channels
      -- * Communicating with other clients
    , readMessages
    , sendMessage
    ) where

------------------------------------------------------------------------

import qualified Network.MPD.Applicative.Internal as A
import qualified Network.MPD.Applicative.ClientToClient as A
import           Network.MPD.Core

------------------------------------------------------------------------

subscribe :: MonadMPD m => A.ChannelName -> m ()
subscribe :: ChannelName -> m ()
subscribe = Command () -> m ()
forall (m :: * -> *) a. MonadMPD m => Command a -> m a
A.runCommand (Command () -> m ())
-> (ChannelName -> Command ()) -> ChannelName -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChannelName -> Command ()
A.subscribe

unsubscribe :: MonadMPD m => A.ChannelName -> m ()
unsubscribe :: ChannelName -> m ()
unsubscribe = Command () -> m ()
forall (m :: * -> *) a. MonadMPD m => Command a -> m a
A.runCommand (Command () -> m ())
-> (ChannelName -> Command ()) -> ChannelName -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChannelName -> Command ()
A.subscribe

channels :: MonadMPD m => m [A.ChannelName]
channels :: m [ChannelName]
channels = Command [ChannelName] -> m [ChannelName]
forall (m :: * -> *) a. MonadMPD m => Command a -> m a
A.runCommand Command [ChannelName]
A.channels

readMessages :: MonadMPD m => m [(A.ChannelName, A.MessageText)]
readMessages :: m [(ChannelName, ChannelName)]
readMessages = Command [(ChannelName, ChannelName)]
-> m [(ChannelName, ChannelName)]
forall (m :: * -> *) a. MonadMPD m => Command a -> m a
A.runCommand Command [(ChannelName, ChannelName)]
A.readMessages

sendMessage :: MonadMPD m => A.ChannelName -> A.MessageText -> m ()
sendMessage :: ChannelName -> ChannelName -> m ()
sendMessage ChannelName
name ChannelName
text = Command () -> m ()
forall (m :: * -> *) a. MonadMPD m => Command a -> m a
A.runCommand (ChannelName -> ChannelName -> Command ()
A.sendMessage ChannelName
name ChannelName
text)