domotics-core 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/domotics/core/element.rb +1 -1
- data/lib/domotics/core/helper/helper.rb +1 -1
- data/lib/domotics/core/room.rb +1 -1
- data/lib/domotics/core/server.rb +1 -3
- data/lib/domotics/core/version.rb +1 -1
- data/lib/domotics/core/ws_server.rb +13 -7
- data/lib/domotics/file_camera/camera_element.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02ebecc7f97e80de2536f358cecad8575b774fe0
|
4
|
+
data.tar.gz: 5883efe2e1f49b13f602956ddfcbbc79f532709e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e27789dbc3e14975c31f149778d2855b28b63c019e3e0afd341fd693e43469bd8ff6f279d4cda8802233400487eee5738f226e98b4f5030bcb9fea624f94407e
|
7
|
+
data.tar.gz: 9ba2b8410f2e8b945f577f0988906e1bdd4adc8d569dad18231c27126b53fe3b707caf3291d063086841062e2fe3a4ad2d66b0d734b3ff2df5492913bb0bd4c1
|
data/lib/domotics/core/room.rb
CHANGED
@@ -57,7 +57,7 @@ module Domotics::Core
|
|
57
57
|
# Default - simple prints event
|
58
58
|
def event_handler(msg = {})
|
59
59
|
event, element = msg[:event], msg[:element]
|
60
|
-
@logger.info { "
|
60
|
+
@logger.info { "[Domotics] event [#{event}] element [#{element}] state [#{element.state}]" }
|
61
61
|
Domotics::Core::WsServer.publish "#{element.room.name}/#{element.name}"
|
62
62
|
end
|
63
63
|
|
data/lib/domotics/core/server.rb
CHANGED
@@ -1,28 +1,34 @@
|
|
1
1
|
module Domotics::Core
|
2
2
|
class WsServer
|
3
|
-
@@
|
3
|
+
@@parent = nil
|
4
4
|
def initialize(args = {})
|
5
5
|
@logger = Domotics::Core::Setup.logger || Logger.new(STDERR)
|
6
6
|
@args = args
|
7
|
+
@@parent, @child = Socket.pair(:UNIX, :DGRAM, 0)
|
7
8
|
end
|
8
9
|
def run
|
9
|
-
|
10
|
-
|
10
|
+
@logger.info { "[WebSocket] server [#{@args[:host]}:#{@args[:port]}]" }
|
11
|
+
fork do
|
12
|
+
@@parent.close
|
13
|
+
channel = EventMachine::Channel.new
|
14
|
+
Thread.new { loop { channel.push @child.recv(2**10) }}
|
11
15
|
EventMachine::WebSocket.start(@args) do |ws|
|
12
16
|
ws.onopen do
|
13
|
-
sid =
|
17
|
+
sid = channel.subscribe { |msg| ws.send msg }
|
18
|
+
@logger.info { "[WebSocket] client [#{sid}]" }
|
14
19
|
ws.onmessage do |msg|
|
15
|
-
@logger.info { "WebSocket message [#{msg}] from
|
20
|
+
@logger.info { "[WebSocket] message [#{msg}] from [#{sid}]" }
|
16
21
|
end
|
17
22
|
ws.onclose do
|
18
|
-
|
23
|
+
channel.unsubscribe(sid)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
28
|
+
@child.close
|
23
29
|
end
|
24
30
|
def self.publish(msg)
|
25
|
-
@@
|
31
|
+
@@parent.send msg, 0 if @@parent
|
26
32
|
end
|
27
33
|
end
|
28
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domotics-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- goredar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: domotics-arduino
|