obsws 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 339b5706222511d0cf272eff7040f45dc5bc1cffdfdc6b6d0cc59ea299c325e1
4
- data.tar.gz: 2070c51a27e764297d2555bd958411fd8ee06c49f98bd09fa6144f7fba5790c8
3
+ metadata.gz: 951d942da5f3b7b0895acdd2921ac74b1fa21a1f3e4a56e58ea58c053ca2a51e
4
+ data.tar.gz: 5f1c953ecfe4b187b63f2aae17cae497e5475dc049c7fb06a5d84451795e7ae3
5
5
  SHA512:
6
- metadata.gz: c80761585030c73bd304de37ead5ea8f5260116f7e2acb6a15549d920695be579c0fc0ffa9f0485569ffd56f4c11b6ca027711eeadb2ecb81c8b9b3016e68396
7
- data.tar.gz: 13fc659eb70544b51555cb9f68608927f64671377f550ae78c3d9a83b60de2f42050d17403ae72aeb701525fc15e48a5086d37f05c780b4055a24cfe252bd0a1
6
+ metadata.gz: c6aacbdc428e859c97669718b2df5f447fb6a136dd9def91b87613c40b7f25798236db96ddb3c29d629b30dbcebc8250f2566334fa5c82572eec4d9cf64e140f
7
+ data.tar.gz: d2729c6a1d9c50c37dac5f204d2d654375822b3f70911a420ba81b386d75f8afa2e5f7ead8cce0e496b12d221afeacaa9987119465136da19342c42785fc7102
data/CHANGELOG.md CHANGED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Before any major/minor/patch bump all unit tests will be run to verify they pass.
9
+
10
+ ## [0.0.1] - 2021-10-22
11
+
12
+ ### Added
13
+
14
+ - Initial Commit
15
+ - Base class, Request and Event client classes.
16
+ - Unit tests
17
+ - README.md
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Onyx and Iris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  pass `host`, `port` and `password` as keyword arguments.
18
18
 
19
19
  ```ruby
20
- require_relative "lib/obsws"
20
+ require "obsws"
21
21
 
22
22
  def main
23
23
  r_client =
data/lib/obsws/base.rb CHANGED
@@ -37,11 +37,8 @@ module OBSWS
37
37
  @socket = TCPSocket.new(host, port)
38
38
  @driver =
39
39
  WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
40
- @ready = false
41
- @closed = false
42
40
  @driver.on :open do |msg|
43
41
  LOGGER.debug("driver socket open")
44
- @ready = true
45
42
  end
46
43
  @driver.on :close do |msg|
47
44
  LOGGER.debug("driver socket closed")
@@ -51,21 +48,23 @@ module OBSWS
51
48
  LOGGER.debug("received [#{msg}] passing to handler")
52
49
  msg_handler(JSON.parse(msg.data, symbolize_names: true))
53
50
  end
54
- Thread.new { start_driver }
51
+ start_driver
55
52
  WaitUtil.wait_for_condition(
56
- "driver socket ready",
53
+ "waiting authentication successful",
57
54
  delay_sec: 0.01,
58
- timeout_sec: 0.5
59
- ) { @ready }
55
+ timeout_sec: 3
56
+ ) { @authenticated }
60
57
  end
61
58
 
62
59
  def start_driver
63
- @driver.start
60
+ Thread.new do
61
+ @driver.start
64
62
 
65
- loop do
66
- @driver.parse(@socket.readpartial(4096))
67
- rescue EOFError
68
- break
63
+ loop do
64
+ @driver.parse(@socket.readpartial(4096))
65
+ rescue EOFError
66
+ break
67
+ end
69
68
  end
70
69
  end
71
70
 
@@ -85,6 +84,7 @@ module OBSWS
85
84
  eventSubscriptions: @subs
86
85
  }
87
86
  }
87
+ LOGGER.debug("initiating authentication")
88
88
  @driver.text(JSON.generate(payload))
89
89
  end
90
90
 
@@ -92,9 +92,11 @@ module OBSWS
92
92
  op_code = data[:op]
93
93
  case op_code
94
94
  when Mixin::OPCodes::HELLO
95
+ LOGGER.debug("hello received, passing to auth")
95
96
  authenticate(data[:d][:authentication])
96
97
  when Mixin::OPCodes::IDENTIFIED
97
- LOGGER.debug("Authentication successful")
98
+ LOGGER.debug("authentication successful")
99
+ @authenticated = true
98
100
  when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
99
101
  changed
100
102
  notify_observers(op_code, data[:d])
data/lib/obsws/req.rb CHANGED
@@ -51,6 +51,10 @@ module OBSWS
51
51
  raise OBSWSError.new(error.join("\n"))
52
52
  end
53
53
  @response[:responseData]
54
+ rescue WaitUtil::TimeoutError
55
+ msg = "no response with matching id received"
56
+ LOGGER.error(msg)
57
+ raise OBSWSError.new(msg)
54
58
  end
55
59
 
56
60
  def get_version
data/lib/obsws/version.rb CHANGED
@@ -11,7 +11,7 @@ module OBSWS
11
11
  end
12
12
 
13
13
  def patch
14
- 1
14
+ 2
15
15
  end
16
16
 
17
17
  def to_a
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.0.1
4
+ version: 0.0.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-10-22 00:00:00.000000000 Z
11
+ date: 2022-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: observer
@@ -106,15 +106,17 @@ dependencies:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 11.2.2
109
- description: A Ruby wrapper around the OBS Websocket v5 protocol
109
+ description: A Ruby wrapper around OBS Websocket v5
110
110
  email: code@onyxandiris.online
111
111
  executables: []
112
112
  extensions: []
113
113
  extra_rdoc_files:
114
114
  - README.md
115
115
  - CHANGELOG.md
116
+ - LICENSE
116
117
  files:
117
118
  - CHANGELOG.md
119
+ - LICENSE
118
120
  - README.md
119
121
  - lib/obsws.rb
120
122
  - lib/obsws/base.rb
@@ -144,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
146
  - !ruby/object:Gem::Version
145
147
  version: '0'
146
148
  requirements: []
147
- rubygems_version: 3.3.12
149
+ rubygems_version: 3.3.7
148
150
  signing_key:
149
151
  specification_version: 4
150
152
  summary: OBS Websocket v5 wrapper