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.
35 36 37 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 35 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.
42 43 44 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 42 def send_command :readmessages end |
#sendmessage(channel, message) ⇒ Boolean
Send a message to the specified channel.
50 51 52 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 50 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.
22 23 24 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 22 def subscribe(channel) send_command :subscribe, channel end |
#unsubscribe(channel) ⇒ Boolean
Unsubscribe from a channel.
29 30 31 |
# File 'lib/ruby-mpd/plugins/channels.rb', line 29 def unsubscribe(channel) send_command :unsubscribe, channel end |