Module: MPD::Plugins::Channels
- Included in:
- MPD
- Defined in:
- lib/ruby-mpd/plugins/channels.rb
Overview
Client to client commands
Clients can communicate with each others over “channels”. A channel is created by a client subscribing to it. More than one client can be subscribed to a channel at a time; all of them will receive the messages which get sent to it.
Each time a client subscribes or unsubscribes, the global idle event subscription is generated. In conjunction with the channels command, this may be used to auto-detect clients providing additional services.
New messages are indicated by the message idle event.
Instance Method Summary collapse
-
#channels ⇒ Array<String>, ...
Obtain a list of all channels.
-
#readmessages ⇒ Array<Hash>, ...
Reads messages for this client.
-
#sendmessage(channel, message) ⇒ Boolean
Send a message to the specified channel.
-
#subscribe(channel) ⇒ Boolean
Subscribe to a channel.
-
#unsubscribe(channel) ⇒ Boolean
Unsubscribe from a channel.
Instance Method Details
#channels ⇒ Array<String>, ...
Obtain a list of all channels.
36 37 38 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 36 def channels send_command :channels end |
#readmessages ⇒ Array<Hash>, ...
Reads messages for this client. The response is an array of hashes with :channel
and :message
keys or true if no messages.
45 46 47 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 45 def send_command :readmessages end |
#sendmessage(channel, message) ⇒ Boolean
Send a message to the specified channel.
53 54 55 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 53 def (channel, ) send_command :sendmessage, channel, end |
#subscribe(channel) ⇒ Boolean
Subscribe to a channel. The channel is created if it does not exist already. The name may consist of alphanumeric ASCII characters plus underscore, dash, dot and colon.
21 22 23 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 21 def subscribe(channel) send_command :subscribe, channel end |
#unsubscribe(channel) ⇒ Boolean
Unsubscribe from a channel.
28 29 30 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 28 def unsubscribe(channel) send_command :unsubscribe, channel end |