Class: Mumble::Client
- Inherits:
-
Object
- Object
- Mumble::Client
- Defined in:
- lib/mumble-ruby/client.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #connect ⇒ Object
- #current_channel ⇒ Object
- #deafen(bool = true) ⇒ Object
- #disconnect ⇒ Object
- #find_channel(name) ⇒ Object
- #find_user(name) ⇒ Object
-
#initialize(host, port = 64738, username = "Ruby Client", password = "") ⇒ Client
constructor
A new instance of Client.
- #join_channel(channel) ⇒ Object
- #me ⇒ Object
- #mute(bool = true) ⇒ Object
- #stream_raw_audio(file) ⇒ Object
- #text_channel(channel, string) ⇒ Object
- #text_user(user, string) ⇒ Object
- #user_stats(user) ⇒ Object
Constructor Details
#initialize(host, port = 64738, username = "Ruby Client", password = "") ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 |
# File 'lib/mumble-ruby/client.rb', line 14 def initialize(host, port=64738, username="Ruby Client", password="") @host = host @port = port @username = username @password = password @users, @channels = {}, {} @callbacks = Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def channels @channels end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def username @username end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
12 13 14 |
# File 'lib/mumble-ruby/client.rb', line 12 def users @users end |
Instance Method Details
#connect ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mumble-ruby/client.rb', line 23 def connect @conn = Connection.new @host, @port @conn.connect create_encoder version_exchange authenticate init_callbacks @read_thread = spawn_thread :read @ping_thread = spawn_thread :ping end |
#current_channel ⇒ Object
47 48 49 |
# File 'lib/mumble-ruby/client.rb', line 47 def current_channel @channels[me.channel_id] end |
#deafen(bool = true) ⇒ Object
70 71 72 |
# File 'lib/mumble-ruby/client.rb', line 70 def deafen(bool=true) send_user_state self_deaf: bool end |
#disconnect ⇒ Object
36 37 38 39 40 41 |
# File 'lib/mumble-ruby/client.rb', line 36 def disconnect @encoder.destroy @read_thread.kill @ping_thread.kill @conn.disconnect end |
#find_channel(name) ⇒ Object
103 104 105 |
# File 'lib/mumble-ruby/client.rb', line 103 def find_channel(name) @channels.values.find { |u| u.name == name } end |
#find_user(name) ⇒ Object
99 100 101 |
# File 'lib/mumble-ruby/client.rb', line 99 def find_user(name) @users.values.find { |u| u.name == name } end |
#join_channel(channel) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/mumble-ruby/client.rb', line 74 def join_channel(channel) send_user_state({ session: me.session, channel_id: channel_id(channel) }) end |
#me ⇒ Object
43 44 45 |
# File 'lib/mumble-ruby/client.rb', line 43 def me @users[@session] end |
#mute(bool = true) ⇒ Object
66 67 68 |
# File 'lib/mumble-ruby/client.rb', line 66 def mute(bool=true) send_user_state self_mute: bool end |
#stream_raw_audio(file) ⇒ Object
51 52 53 54 |
# File 'lib/mumble-ruby/client.rb', line 51 def stream_raw_audio(file) raise NoSupportedCodec unless @codec AudioStream.new(@codec, 0, @encoder, file, @conn) end |
#text_channel(channel, string) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/mumble-ruby/client.rb', line 88 def text_channel(channel, string) ({ channel_id: [channel_id(channel)], message: string }) end |
#text_user(user, string) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/mumble-ruby/client.rb', line 81 def text_user(user, string) ({ session: [user_session(user)], message: string }) end |
#user_stats(user) ⇒ Object
95 96 97 |
# File 'lib/mumble-ruby/client.rb', line 95 def user_stats(user) send_user_stats session: user_session(user) end |