obsws 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/LICENSE +21 -0
- data/README.md +2 -1
- data/lib/obsws/base.rb +22 -19
- data/lib/obsws/req.rb +4 -0
- data/lib/obsws/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 459330fa7270cc31f26449b15ceb03e53130a7499f3272a9a9d17d8ac7de0b7f
|
4
|
+
data.tar.gz: 46897d76b4c62720f776aabb2fea69d47fadc9a0c1d1b0041d090738e2a9c394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9bf8c54c209f1b18422babb02fcc631f773e0a5d46c9b8af49ba1a6e5e3077de1b89e1ce57cbc36fb5e868c41503a57d49292cc5bcb970c39127493bb1be3b5
|
7
|
+
data.tar.gz: 5959a9b71dceaf3af1fdbe624828e22631e45c8845e2ce232e9083565b9d62aa294690212ecc8b35f56083bb39eed94c346acf787f854414af072edbf3c9b2c8
|
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
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/obsws.svg)](https://badge.fury.io/rb/obsws)
|
1
2
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/voicemeeter-api-ruby/blob/dev/LICENSE)
|
2
3
|
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/plugin-ruby)
|
3
4
|
|
@@ -17,7 +18,7 @@
|
|
17
18
|
pass `host`, `port` and `password` as keyword arguments.
|
18
19
|
|
19
20
|
```ruby
|
20
|
-
|
21
|
+
require "obsws"
|
21
22
|
|
22
23
|
def main
|
23
24
|
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
|
-
|
51
|
+
start_driver
|
55
52
|
WaitUtil.wait_for_condition(
|
56
|
-
"
|
53
|
+
"waiting successful identification",
|
57
54
|
delay_sec: 0.01,
|
58
|
-
timeout_sec:
|
59
|
-
) { @
|
55
|
+
timeout_sec: 3
|
56
|
+
) { @identified }
|
60
57
|
end
|
61
58
|
|
62
59
|
def start_driver
|
63
|
-
|
60
|
+
Thread.new do
|
61
|
+
@driver.start
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
loop do
|
64
|
+
@driver.parse(@socket.readpartial(4096))
|
65
|
+
rescue EOFError
|
66
|
+
break
|
67
|
+
end
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
@@ -75,29 +74,33 @@ module OBSWS
|
|
75
74
|
)
|
76
75
|
end
|
77
76
|
|
78
|
-
def authenticate(auth)
|
79
|
-
token = auth_token(**auth)
|
77
|
+
def authenticate(auth = nil)
|
80
78
|
payload = {
|
81
79
|
op: Mixin::OPCodes::IDENTIFY,
|
82
80
|
d: {
|
83
81
|
rpcVersion: 1,
|
84
|
-
authentication: token,
|
85
82
|
eventSubscriptions: @subs
|
86
83
|
}
|
87
84
|
}
|
85
|
+
payload[:d][:authentication] = auth_token(**auth) if auth
|
88
86
|
@driver.text(JSON.generate(payload))
|
89
87
|
end
|
90
88
|
|
91
89
|
def msg_handler(data)
|
92
|
-
|
93
|
-
case op_code
|
90
|
+
case data[:op]
|
94
91
|
when Mixin::OPCodes::HELLO
|
92
|
+
if data[:d].key? :authentication
|
93
|
+
LOGGER.debug("initiating authentication")
|
94
|
+
else
|
95
|
+
LOGGER.debug("authentication disabled... skipping.")
|
96
|
+
end
|
95
97
|
authenticate(data[:d][:authentication])
|
96
98
|
when Mixin::OPCodes::IDENTIFIED
|
97
|
-
LOGGER.debug("
|
99
|
+
LOGGER.debug("client succesfully identified with server")
|
100
|
+
@identified = true
|
98
101
|
when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
|
99
102
|
changed
|
100
|
-
notify_observers(
|
103
|
+
notify_observers(data[:op], data[:d])
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
data/lib/obsws/req.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.3
|
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-
|
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
|
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
|