universal_dom_remote 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf972103a9be7e94fa460e3c3f0b9cd1d499ef98
4
+ data.tar.gz: dc7afd9a574dafaa7314a48dc8c9e7f3d35aab1d
5
+ SHA512:
6
+ metadata.gz: 897e7f35a7a274323220509074c1d2dad18ff2742f826e8e675c75707a423b41489818cb359ba842ad002e33a48a8bef8c14d627f4fbd03dfa75da5f0df2e906
7
+ data.tar.gz: f7215f927c221bbe81916c5283cb812508cfaad2fa71437b6cf24fd22925ce146feffe4289284bb8d3b429fc5b912ce1c5576622de4a5ff6784e4b7712fd28fe
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: universal_dom_remote.rb
4
+
5
+
6
+ require 'sps_duplex'
7
+
8
+
9
+ class UniversalDomRemoteException < Exception
10
+ end
11
+
12
+ class UniversalDomRemote < SPSDuplex
13
+
14
+ def initialize(debug: false)
15
+
16
+ super(host: '127.0.0.1', port: '55000', topic: 'udr',
17
+ sub_topic: 'browser', pub_topic: 'controller')
18
+
19
+ @debug = debug
20
+ @received = []
21
+
22
+ end
23
+
24
+ # A helpful method to generate the javascript code necessary for the
25
+ # web browser to communicate with the universal DOM remote
26
+ #
27
+ def javascript()
28
+
29
+ "
30
+ var ws = new WebSocket('ws://127.0.0.1:55000/');
31
+ ws.onopen = function() {
32
+ console.log('CONNECT');
33
+ ws.send('subscribe to topic: udr/controller');
34
+ };
35
+ ws.onclose = function() {
36
+ console.log('DISCONNECT');
37
+ };
38
+ ws.onmessage = function(event) {
39
+
40
+ var a = event.data.split(/: +/,2);
41
+ console.log(a[1]);
42
+
43
+ try {
44
+ r = eval(a[1]);
45
+ }
46
+ catch(err) {
47
+ r = err.message;
48
+ }
49
+
50
+ ws.send('udr/browser: ' + r);
51
+
52
+ };
53
+ "
54
+
55
+ end
56
+
57
+ # used by the callback routine
58
+ #
59
+ def ontopic(topic, msg)
60
+
61
+ a = topic.split('/')
62
+ sender = a.pop
63
+
64
+ puts "%s: %s" % [sender, msg] if @debug
65
+ @received << msg
66
+
67
+ end
68
+
69
+ # send the instruction to the web browser
70
+ #
71
+ def send(s, timeout: 30)
72
+
73
+ t = Time.now + timeout
74
+
75
+ super(s)
76
+
77
+ sleep 0.1 until @received.any? or Time.now > t
78
+ raise UniversalDomRemoteException, 'recv::timeout' if Time.now > t
79
+
80
+ r = @received.last
81
+ @received = []
82
+
83
+ return r
84
+ end
85
+
86
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: universal_dom_remote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTI5MjE1MTExWhcN
15
+ MTkwMTI5MjE1MTExWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8r84s
17
+ KsjlA+P/UsRPtyLlXf6/L+N6LgOuTaMh0FAEv0yeluI8DJjMLVgBBo8m0GJHrpQ6
18
+ UJCFNO4EZWo1yB01UHei7N5PVmlAGjqFZsgGL+t++VAOR7k85KSZJTo9n/K+ufEz
19
+ oHEl/NvXZUgJG3MW7Icb9UHb38X1jqJ6kEA8LpyIJqvQYyemStHdVphpsijHaE55
20
+ ZJHuw7h59v5s718SMmsNM1oW8GiASOMIBWK4ga4wQFAf60z6vJUYmg9D1YnQI7qc
21
+ E5E6EaB7v3nfeOuI+CbYgxs0mz8dVxZ1UUOTlrudy7bhaguSwhT8MYoT8443j8wI
22
+ ikGlBEsOfNhX6aETAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
+ HQYDVR0OBBYEFJ1P8Dhszopd6QuV3zzHyEc1cb8JMCYGA1UdEQQfMB2BG2dlbW1h
24
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
+ ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBABrcZAtq7mk9I/tZvuuD
26
+ 5aSHNYnQeF8vCf+4YOVO/fySNv0iHIpEZ6GmfcXbqLcbTR/c1jbJC7jjHsYvCa0o
27
+ iGf4PxlIOQ7PbWtaSX2hAo8cvW+tWkWr0qW23I9VaeEc78IZQh7HpELE0Ziu/Kp0
28
+ oLt9vnVxB7rgjPx73EzokiSsy1DAUzw4Ngp0kk5DZMeR9tlyrf02he7Cnp+Mt4n+
29
+ PIVqmhmfZ9YybXbjFOCiJBJI9VGz6Kua0NCQEHBegu2j1oMl1xSS/Hrb8eRvhwnB
30
+ wTGGRYMbyj2jZVB+bTFMyUlOmYtPbMYVDkKNH+yQWpCs2U67WRsG7MzlXHTolRIi
31
+ pVQ=
32
+ -----END CERTIFICATE-----
33
+ date: 2018-01-29 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sps-duplex
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.1'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.1.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '0.1'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
55
+ description:
56
+ email: james@jamesrobertson.eu
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/universal_dom_remote.rb
62
+ homepage: https://github.com/jrobertson/universal_dom_remote
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.6.13
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: 'Interacts with the web browser via websockets using a SimplePubSub broker.
86
+ Note: Tested using Firefox.'
87
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ �?����Գ���Ϟ�b�i� �)�ں;�ҀY[X X�c��N�F�����TD*�aL! >�Iӱ��[�_e}HB� ͺ�.W���eƕ"b��`��� ���]�yc��o��9�Mf�t!��̛�FO�9Ɔ8\jB��'��b��WɹQ����X���ڴ�����דi���3Ի���v�>Y�C
2
+ �H��3@je'����9�