obsws 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +13 -0
 - data/lib/obsws/base.rb +16 -11
 - data/lib/obsws/req.rb +2 -2
 - data/lib/obsws/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c128f9332d398f7aebf7cfa0f25c3e5ab1dbd9a1d3b083699ace811a9a8ecc9c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f587866f6b9546d3d681091f5fd525ba2b8a16f1b243e5f3e49edae61cd79e8e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6386ad4234987f9d527fdadd19674039162b2d446bb7edf1afc44621f65631738f69c1887442f1a99851b82516bbd4f857b13e59999dd987071fd74c9aa8b46a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2e1caa11d9206f3029256796aa56f29a1dd1e41f217859c30d8c7bfd0deecc761cf0ba9ca01bf05952bf7617c22bbcfeae849f0df8856462fadff14f05c1623c
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -115,6 +115,19 @@ If a request fails an `OBSWSError` will be raised with a status code. 
     | 
|
| 
       115 
115 
     | 
    
         | 
| 
       116 
116 
     | 
    
         
             
            For a full list of status codes refer to [Codes](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus)
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
      
 118 
     | 
    
         
            +
            ### Logging
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            To see the raw messages set log level to debug
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            example:
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 125 
     | 
    
         
            +
            require "obsws"
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            OBSWS::LOGGER.debug!
         
     | 
| 
      
 128 
     | 
    
         
            +
            ...
         
     | 
| 
      
 129 
     | 
    
         
            +
            ```
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       118 
131 
     | 
    
         
             
            ### Tests
         
     | 
| 
       119 
132 
     | 
    
         | 
| 
       120 
133 
     | 
    
         
             
            To run all tests:
         
     | 
    
        data/lib/obsws/base.rb
    CHANGED
    
    | 
         @@ -45,12 +45,12 @@ module OBSWS 
     | 
|
| 
       45 
45 
     | 
    
         
             
                    @closed = true
         
     | 
| 
       46 
46 
     | 
    
         
             
                  end
         
     | 
| 
       47 
47 
     | 
    
         
             
                  @driver.on :message do |msg|
         
     | 
| 
       48 
     | 
    
         
            -
                    LOGGER.debug("received  
     | 
| 
      
 48 
     | 
    
         
            +
                    LOGGER.debug("received: #{msg.data}")
         
     | 
| 
       49 
49 
     | 
    
         
             
                    msg_handler(JSON.parse(msg.data, symbolize_names: true))
         
     | 
| 
       50 
50 
     | 
    
         
             
                  end
         
     | 
| 
       51 
51 
     | 
    
         
             
                  start_driver
         
     | 
| 
       52 
52 
     | 
    
         
             
                  WaitUtil.wait_for_condition(
         
     | 
| 
       53 
     | 
    
         
            -
                    " 
     | 
| 
      
 53 
     | 
    
         
            +
                    "successful identification",
         
     | 
| 
       54 
54 
     | 
    
         
             
                    delay_sec: 0.01,
         
     | 
| 
       55 
55 
     | 
    
         
             
                    timeout_sec: 3
         
     | 
| 
       56 
56 
     | 
    
         
             
                  ) { @identified }
         
     | 
| 
         @@ -75,15 +75,20 @@ module OBSWS 
     | 
|
| 
       75 
75 
     | 
    
         
             
                end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
77 
     | 
    
         
             
                def identify(auth)
         
     | 
| 
       78 
     | 
    
         
            -
                   
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                     
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 78 
     | 
    
         
            +
                  if auth
         
     | 
| 
      
 79 
     | 
    
         
            +
                    if @password.empty?
         
     | 
| 
      
 80 
     | 
    
         
            +
                      raise OBSWSError("auth enabled but no password provided")
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                    LOGGER.info("initiating authentication")
         
     | 
| 
      
 83 
     | 
    
         
            +
                    payload = {
         
     | 
| 
      
 84 
     | 
    
         
            +
                      op: Mixin::OPCodes::IDENTIFY,
         
     | 
| 
      
 85 
     | 
    
         
            +
                      d: {
         
     | 
| 
      
 86 
     | 
    
         
            +
                        rpcVersion: 1,
         
     | 
| 
      
 87 
     | 
    
         
            +
                        eventSubscriptions: @subs
         
     | 
| 
      
 88 
     | 
    
         
            +
                      }
         
     | 
| 
       84 
89 
     | 
    
         
             
                    }
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                   
     | 
| 
      
 90 
     | 
    
         
            +
                    payload[:d][:authentication] = auth_token(**auth)
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
       87 
92 
     | 
    
         
             
                  @driver.text(JSON.generate(payload))
         
     | 
| 
       88 
93 
     | 
    
         
             
                end
         
     | 
| 
       89 
94 
     | 
    
         | 
| 
         @@ -108,8 +113,8 @@ module OBSWS 
     | 
|
| 
       108 
113 
     | 
    
         
             
                    }
         
     | 
| 
       109 
114 
     | 
    
         
             
                  }
         
     | 
| 
       110 
115 
     | 
    
         
             
                  payload[:d][:requestData] = data if data
         
     | 
| 
      
 116 
     | 
    
         
            +
                  LOGGER.debug("sending request: #{payload}")
         
     | 
| 
       111 
117 
     | 
    
         
             
                  queued = @driver.text(JSON.generate(payload))
         
     | 
| 
       112 
     | 
    
         
            -
                  LOGGER.debug("request with id #{id} queued? #{queued}")
         
     | 
| 
       113 
118 
     | 
    
         
             
                end
         
     | 
| 
       114 
119 
     | 
    
         
             
              end
         
     | 
| 
       115 
120 
     | 
    
         
             
            end
         
     | 
    
        data/lib/obsws/req.rb
    CHANGED
    
    | 
         @@ -28,7 +28,7 @@ module OBSWS 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  ensure
         
     | 
| 
       29 
29 
     | 
    
         
             
                    close
         
     | 
| 
       30 
30 
     | 
    
         
             
                    WaitUtil.wait_for_condition(
         
     | 
| 
       31 
     | 
    
         
            -
                      "driver  
     | 
| 
      
 31 
     | 
    
         
            +
                      "driver to close",
         
     | 
| 
       32 
32 
     | 
    
         
             
                      delay_sec: 0.01,
         
     | 
| 
       33 
33 
     | 
    
         
             
                      timeout_sec: 1
         
     | 
| 
       34 
34 
     | 
    
         
             
                    ) { @base_client.closed }
         
     | 
| 
         @@ -42,7 +42,7 @@ module OBSWS 
     | 
|
| 
       42 
42 
     | 
    
         
             
                    id = rand(1..1000)
         
     | 
| 
       43 
43 
     | 
    
         
             
                    @base_client.req(id, req, data)
         
     | 
| 
       44 
44 
     | 
    
         
             
                    WaitUtil.wait_for_condition(
         
     | 
| 
       45 
     | 
    
         
            -
                      "reponse id  
     | 
| 
      
 45 
     | 
    
         
            +
                      "reponse id to match request id",
         
     | 
| 
       46 
46 
     | 
    
         
             
                      delay_sec: 0.001,
         
     | 
| 
       47 
47 
     | 
    
         
             
                      timeout_sec: 3
         
     | 
| 
       48 
48 
     | 
    
         
             
                    ) { @response[:requestId] == id }
         
     | 
    
        data/lib/obsws/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: obsws
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - onyx_online
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-11-25 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: observer
         
     |