obsws 0.3.0 → 0.3.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: f55dbfe2267a8b2dec6fc0c347b537b1a9727de641ec762d16128a40ee3397a4
4
- data.tar.gz: 3ef38f6bfb12db426c31afdb130e25debda7173e135daf9d88677d6002365c55
3
+ metadata.gz: e5e9cb2c558346b12dde7736519342ede8d4e0a366b1bd8b6e6d16df3009cafc
4
+ data.tar.gz: bbafa4a7fdd292d4469d8ff368dbc42e97da22cd2551da2c57728928d19d70ce
5
5
  SHA512:
6
- metadata.gz: c2914cfd19dd1107ecd0d8825ca5386b9e6574983527098801fed5f0ed3c06520490f139d9c3837d45aa2791cd8e20e263b07ada46d46d7957a399aebd629ad2
7
- data.tar.gz: 1d76544ea453fc16bad1d38b64ff4328ad1665520323112694007377e75959ce78f05027cfb85ef176b74148374f15c60b03b627f92552e6741171919f930c37
6
+ metadata.gz: 05abfc47adc6b94e75acc55277fc78856f4cf9c003c358c16e447323d779435c1bb1f11654bde7665afdb67c6a063ec510e147a085b41a540af6e2881e4efaf9
7
+ data.tar.gz: 3472fa88a6704b2c91e016b8edc9aade0d47e43b42997c9647b2306fea627d79cbb240193731abb374d9798cca08c76e69fc1a0061fdf4b0ab8dceec1b6a9ae5
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/obsws-ruby/blob/dev/LICENSE)
3
3
  [![Ruby Code Style](https://img.shields.io/badge/code_style-standard-violet.svg)](https://github.com/standardrb/standard)
4
4
 
5
- # A Ruby wrapper around OBS Studio WebSocket v5.0
5
+ # Ruby Clients for OBS Studio WebSocket v5.0
6
6
 
7
7
  ## Requirements
8
8
 
data/lib/obsws/base.rb CHANGED
@@ -1,29 +1,16 @@
1
- require "socket"
2
- require "websocket/driver"
3
1
  require "digest/sha2"
4
2
  require "json"
5
3
  require "waitutil"
6
4
 
7
- require_relative "mixin"
5
+ require_relative "driver"
8
6
  require_relative "error"
9
7
  require_relative "logger"
8
+ require_relative "mixin"
10
9
 
11
10
  module OBSWS
12
- class Socket
13
- attr_reader :url
14
-
15
- def initialize(url, socket)
16
- @url = url
17
- @socket = socket
18
- end
19
-
20
- def write(s)
21
- @socket.write(s)
22
- end
23
- end
24
-
25
11
  class Base
26
12
  include Logging
13
+ include Driver::Director
27
14
  include Mixin::OPCodes
28
15
 
29
16
  attr_reader :closed
@@ -34,20 +21,7 @@ module OBSWS
34
21
  port = kwargs[:port] || 4455
35
22
  @password = kwargs[:password] || ""
36
23
  @subs = kwargs[:subs] || 0
37
-
38
- @socket = TCPSocket.new(host, port)
39
- @driver =
40
- WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
41
- @driver.on :open do |msg|
42
- logger.debug("driver socket open")
43
- end
44
- @driver.on :close do |msg|
45
- logger.debug("driver socket closed")
46
- @closed = true
47
- end
48
- @driver.on :message do |msg|
49
- msg_handler(JSON.parse(msg.data, symbolize_names: true))
50
- end
24
+ setup_driver(host, port)
51
25
  start_driver
52
26
  WaitUtil.wait_for_condition(
53
27
  "successful identification",
@@ -56,22 +30,6 @@ module OBSWS
56
30
  ) { @identified }
57
31
  end
58
32
 
59
- private def start_driver
60
- Thread.new do
61
- @driver.start
62
-
63
- loop do
64
- @driver.parse(@socket.readpartial(4096))
65
- rescue EOFError
66
- break
67
- end
68
- end
69
- end
70
-
71
- public def stop_driver
72
- @driver.close
73
- end
74
-
75
33
  private
76
34
 
77
35
  def auth_token(salt:, challenge:)
@@ -0,0 +1,53 @@
1
+ require "socket"
2
+ require "websocket/driver"
3
+
4
+ module OBSWS
5
+ module Driver
6
+ class Socket
7
+ attr_reader :url
8
+
9
+ def initialize(url, socket)
10
+ @url = url
11
+ @socket = socket
12
+ end
13
+
14
+ def write(s)
15
+ @socket.write(s)
16
+ end
17
+ end
18
+
19
+ module Director
20
+ def setup_driver(host, port)
21
+ @socket = TCPSocket.new(host, port)
22
+ @driver =
23
+ WebSocket::Driver.client(Socket.new("ws://#{host}:#{port}", @socket))
24
+ @driver.on :open do |msg|
25
+ logger.debug("driver socket open")
26
+ end
27
+ @driver.on :close do |msg|
28
+ logger.debug("driver socket closed")
29
+ @closed = true
30
+ end
31
+ @driver.on :message do |msg|
32
+ msg_handler(JSON.parse(msg.data, symbolize_names: true))
33
+ end
34
+ end
35
+
36
+ private def start_driver
37
+ Thread.new do
38
+ @driver.start
39
+
40
+ loop do
41
+ @driver.parse(@socket.readpartial(4096))
42
+ rescue EOFError
43
+ break
44
+ end
45
+ end
46
+ end
47
+
48
+ public def stop_driver
49
+ @driver.close
50
+ end
51
+ end
52
+ end
53
+ end
data/lib/obsws/event.rb CHANGED
@@ -71,7 +71,7 @@ module OBSWS
71
71
  def initialize(**kwargs)
72
72
  kwargs[:subs] ||= SUBS::LOW_VOLUME
73
73
  @base_client = Base.new(**kwargs)
74
- logger.info("#{self} succesfully identified with server")
74
+ logger.info("#{self} successfully identified with server")
75
75
  @base_client.updater = ->(op_code, data) {
76
76
  if op_code == Mixin::OPCodes::EVENT
77
77
  logger.debug("received: #{data}")
data/lib/obsws/req.rb CHANGED
@@ -16,7 +16,7 @@ module OBSWS
16
16
 
17
17
  def initialize(**kwargs)
18
18
  @base_client = Base.new(**kwargs)
19
- logger.info("#{self} succesfully identified with server")
19
+ logger.info("#{self} successfully identified with server")
20
20
  @base_client.updater = ->(op_code, data) {
21
21
  logger.debug("response received: #{data}")
22
22
  @response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
data/lib/obsws/version.rb CHANGED
@@ -11,7 +11,7 @@ module OBSWS
11
11
  end
12
12
 
13
13
  def patch
14
- 0
14
+ 2
15
15
  end
16
16
 
17
17
  def to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obsws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - onyx_online
@@ -106,6 +106,7 @@ files:
106
106
  - README.md
107
107
  - lib/obsws.rb
108
108
  - lib/obsws/base.rb
109
+ - lib/obsws/driver.rb
109
110
  - lib/obsws/error.rb
110
111
  - lib/obsws/event.rb
111
112
  - lib/obsws/logger.rb