rkconnect 1.0.0.1 → 1.1.0.1
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 +16 -1
- data/lib/rkconnect.rb +8 -17
- metadata +2 -3
- data/lib/thread_pool.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2006c7c6d43d4d974f76887680c62087d6008c22
|
4
|
+
data.tar.gz: 3db2d557dc86b793f8e9d1ce97bf462a8be90075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806376738c1483111b92e7e264b9af9a23a4366eeb3ea401b166eab0ba02b9db0645e2812ad12fda0c763ba34721af50cb615d436f02e17ada7450009792eac7
|
7
|
+
data.tar.gz: 51443113daa96b68ed6a021f38bee16e0f27d1f7ce809fe2830190a1374e0986cf9d24ccffe8df17c3075ef7bdbb5314801abb663ec355b67a131cc725054868
|
data/README.md
CHANGED
@@ -1 +1,16 @@
|
|
1
|
-
# RKConnect (Roku Connect)
|
1
|
+
# RKConnect (Roku Connect)
|
2
|
+
Provides an interface to connect to a roku, send commands to the roku, and receive roku debugger messages.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
1. 'gem install rkconnect'
|
6
|
+
2. rkc = RKConnect(ip_address_of_roku, &callback_block)
|
7
|
+
3. rkc.post_key("Right") <-- Presses the right button on "roku remote"
|
8
|
+
4. rkc.post_channel('dev') <-- Launches 'dev' application from home screen
|
9
|
+
5. rkc.request_debug('var') <-- Returns all variables currently located on screen
|
10
|
+
|
11
|
+
|
12
|
+
## Roku External Controller DOCS
|
13
|
+
(https://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide)
|
14
|
+
|
15
|
+
## Roku Debugger Commands
|
16
|
+
(https://sdkdocs.roku.com/display/sdkdoc/Debugging+Your+Application)
|
data/lib/rkconnect.rb
CHANGED
@@ -2,8 +2,6 @@ require "net/http"
|
|
2
2
|
require 'net/telnet'
|
3
3
|
require "uri"
|
4
4
|
|
5
|
-
require_relative 'thread_pool'
|
6
|
-
|
7
5
|
class RKConnect
|
8
6
|
# include Observer
|
9
7
|
DEBUGGER_PORT = '8085'
|
@@ -15,23 +13,20 @@ class RKConnect
|
|
15
13
|
raise 'Invalid ip_address.' if ip_address.split('.').size != 4
|
16
14
|
raise 'No callback block was passed in. Make sure a block is passed in as an argument.' if block == nil
|
17
15
|
|
18
|
-
@model_call = false
|
19
|
-
|
20
16
|
#Set two different ip addresses. One is just the ip address and the other 'http' is used to send commands to the roku
|
21
17
|
@ip_address = ip_address
|
22
18
|
@http_address = 'http://' << ip_address << ':'\
|
23
19
|
|
24
|
-
#Single threads could be used, though using a thread pool could provide future possibilites
|
25
|
-
@thread_pool = ThreadPool.new(2)
|
26
20
|
@callback = block
|
27
21
|
|
28
|
-
@roku_debugger = Net::Telnet::new('Host' => @ip_address, 'Port' => DEBUGGER_PORT, 'Telnetmode' => false, 'Waittime' =>
|
22
|
+
@roku_debugger = Net::Telnet::new('Host' => @ip_address, 'Port' => DEBUGGER_PORT, 'Telnetmode' => false, 'Waittime' => 0.5)
|
29
23
|
end
|
30
24
|
|
31
25
|
def post_key(key)
|
32
26
|
raise 'Invalid key type. Need a string arg' if !key.is_a? String
|
33
27
|
|
34
|
-
Net::HTTP.post_form(URI(@http_address + EXTERNAL_C_PORT + "/keypress/#{key}"), {})
|
28
|
+
Net::HTTP.post_form(URI(@http_address + EXTERNAL_C_PORT + "/keypress/#{key}"), {})
|
29
|
+
sleep 0.25
|
35
30
|
end
|
36
31
|
|
37
32
|
def post_channel(app_id)
|
@@ -39,6 +34,7 @@ class RKConnect
|
|
39
34
|
raise 'Invalid app_id type. Need a string arg' if !app_id.is_a? String
|
40
35
|
|
41
36
|
Net::HTTP.post_form(URI(@http_address + EXTERNAL_C_PORT + "/launch/#{app_id}"), {})
|
37
|
+
sleep 0.25
|
42
38
|
end
|
43
39
|
|
44
40
|
def request_channel_listing()
|
@@ -51,23 +47,18 @@ class RKConnect
|
|
51
47
|
|
52
48
|
callback_string = ' '
|
53
49
|
#Breaks the telnet connection and enters the roku debugger.
|
54
|
-
ignore_exceptions{@roku_debugger.cmd("String" => "\03", "Timeout" => 1)}
|
50
|
+
ignore_exceptions{@roku_debugger.cmd("String" => "\03", "Timeout" => 0.1)}
|
55
51
|
|
56
|
-
@
|
57
|
-
|
58
|
-
callback_string << telnet_callback
|
59
|
-
end
|
52
|
+
@roku_debugger.cmd(request) do | telnet_callback |
|
53
|
+
callback_string << telnet_callback
|
60
54
|
end
|
61
|
-
#There needs to be a sleep here in order to allow the callback for callback_string to return
|
62
|
-
sleep 1
|
63
55
|
|
64
56
|
callback_string.sub!("BrightScript Debugger>", "")
|
65
57
|
array = callback_string.split(/\n/)
|
66
58
|
|
67
59
|
@callback.call(callback_string)
|
68
60
|
|
69
|
-
ignore_exceptions{@roku_debugger.cmd("String" => "cont", "Timeout" => 1)}
|
70
|
-
sleep 1
|
61
|
+
ignore_exceptions{@roku_debugger.cmd("String" => "cont", "Timeout" => 0.1)}
|
71
62
|
end
|
72
63
|
|
73
64
|
def close_connection
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rkconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaiah Soung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An interface that connects to the roku.
|
14
14
|
email:
|
@@ -18,7 +18,6 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- README.md
|
20
20
|
- lib/rkconnect.rb
|
21
|
-
- lib/thread_pool.rb
|
22
21
|
homepage:
|
23
22
|
licenses:
|
24
23
|
- MIT
|
data/lib/thread_pool.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
class ThreadPool
|
2
|
-
attr_reader :pool
|
3
|
-
|
4
|
-
def initialize(size)
|
5
|
-
@size = size
|
6
|
-
@job_queue = Queue.new
|
7
|
-
|
8
|
-
@pool = Array.new(@size) do |i|
|
9
|
-
Thread.new do
|
10
|
-
Thread.current[:id] = i
|
11
|
-
|
12
|
-
catch(:exit) do
|
13
|
-
loop do
|
14
|
-
job, args = @job_queue.pop
|
15
|
-
job.call(*args)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def schedule_jobs(*args, &block)
|
23
|
-
@job_queue << [block, args]
|
24
|
-
end
|
25
|
-
|
26
|
-
def kill()
|
27
|
-
@size.times do
|
28
|
-
schedule_jobs{throw :exit}
|
29
|
-
end
|
30
|
-
|
31
|
-
@pool.map(&:join)
|
32
|
-
end
|
33
|
-
end
|