mirror of
				https://github.com/onyx-and-iris/obsws-ruby.git
				synced 2025-11-03 17:51:46 +00:00 
			
		
		
		
	reword in readme.
remove brackets
This commit is contained in:
		
							parent
							
								
									daa8c6ada1
								
							
						
					
					
						commit
						61c9a7b365
					
				@ -67,7 +67,9 @@ For a full list of requests refer to [Requests](https://github.com/obsproject/ob
 | 
			
		||||
 | 
			
		||||
### Events
 | 
			
		||||
 | 
			
		||||
Register blocks with the Event client using the `on` method. The event data will be passed to the block.
 | 
			
		||||
Register blocks with the Event client using the `on` method. Event tokens should match the event name but snake cased.
 | 
			
		||||
 | 
			
		||||
The event data will be passed to the block.
 | 
			
		||||
 | 
			
		||||
example:
 | 
			
		||||
 | 
			
		||||
@ -76,10 +78,10 @@ class Observer
 | 
			
		||||
    def initialize
 | 
			
		||||
        @e_client = OBSWS::Events::Client.new(host: "localhost", port: 4455, password: "strongpassword")
 | 
			
		||||
        # register blocks on event types.
 | 
			
		||||
        @e_client.on(:current_program_scene_changed) do |data|
 | 
			
		||||
        @e_client.on :current_program_scene_changed do |data|
 | 
			
		||||
          ...
 | 
			
		||||
        end
 | 
			
		||||
        @e_client.on(:input_mute_state_changed) do |data|
 | 
			
		||||
        @e_client.on :input_mute_state_changed do |data|
 | 
			
		||||
          ...
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -6,16 +6,16 @@ class Main
 | 
			
		||||
    @r_client = OBSWS::Requests::Client.new(**kwargs)
 | 
			
		||||
    @e_client = OBSWS::Events::Client.new(**kwargs)
 | 
			
		||||
 | 
			
		||||
    @e_client.on(:current_program_scene_changed) do |data|
 | 
			
		||||
    @e_client.on :current_program_scene_changed do |data|
 | 
			
		||||
      puts "Switched to scene #{data.scene_name}"
 | 
			
		||||
    end
 | 
			
		||||
    @e_client.on(:scene_created) do |data|
 | 
			
		||||
    @e_client.on :scene_created do |data|
 | 
			
		||||
      puts "scene #{data.scene_name} has been created"
 | 
			
		||||
    end
 | 
			
		||||
    @e_client.on(:input_mute_state_changed) do |data|
 | 
			
		||||
    @e_client.on :input_mute_state_changed do |data|
 | 
			
		||||
      puts "#{data.input_name} mute toggled"
 | 
			
		||||
    end
 | 
			
		||||
    @e_client.on(:exit_started) do
 | 
			
		||||
    @e_client.on :exit_started do
 | 
			
		||||
      puts "OBS closing!"
 | 
			
		||||
      @r_client.close
 | 
			
		||||
      @e_client.close
 | 
			
		||||
 | 
			
		||||
@ -14,12 +14,12 @@ class Main
 | 
			
		||||
    subs = OBSWS::Events::SUBS::LOW_VOLUME | OBSWS::Events::SUBS::INPUTVOLUMEMETERS
 | 
			
		||||
    @e_client = OBSWS::Events::Client.new(subs:, **kwargs)
 | 
			
		||||
 | 
			
		||||
    @e_client.on(:input_mute_state_changed) do |data|
 | 
			
		||||
    @e_client.on :input_mute_state_changed do |data|
 | 
			
		||||
      if data.input_name == DEVICE
 | 
			
		||||
        puts "#{DEVICE} mute toggled"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    @e_client.on(:input_volume_meters) do |data|
 | 
			
		||||
    @e_client.on :input_volume_meters do |data|
 | 
			
		||||
      fget = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
 | 
			
		||||
 | 
			
		||||
      data.inputs.each do |d|
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user