live 0.4.0 → 0.5.0

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: 53a3a21f8a7de949ee8da7c7a0fe6dce23d96312a067319ffcabba644265353b
4
- data.tar.gz: 178c8cc94c77b80f030367995fdc409e583bdff9687c0bbb1355c70548f86e7e
3
+ metadata.gz: e6f7751e42637cac42f2129ab5acbe1ef1c5109a10ef8f1c380b98e2d986829b
4
+ data.tar.gz: f7686de5fa9fd454568d4ccc5735b9146b70a23643e7611da6a0578d5b1213c9
5
5
  SHA512:
6
- metadata.gz: 70a8976aac2a661c412f98a08aa7b310faf56438053ae2661739d90c241a989b4fbfd7ed01d03c4d8e1df390cb8e4243e7c3beeff5ba8edf0d7a59c4b1007da3
7
- data.tar.gz: e502e8cd52a9dc0509746e877ba3810d9544e514e9b83819870d12417311b7b114be15be845ea2fb169cc4b11cf144a68274e017009bf4af628cf575f5349b17
6
+ metadata.gz: 5dbd73c760708403ad2d16c4343bfc850fd381bb1d37c6d129327015597653227c8b812d6e3eea34b23960cc87d849f9a6cefa97d3154e17c2c6236dbcc7fe33
7
+ data.tar.gz: 613b770cfeb6c1ef2bfd9b0972186e92361ba4774d3b6786b24bceb698da82ced5b817b5427cff6994a88a692e52b77448d490448761b277f53b7374b86becfe
checksums.yaml.gz.sig ADDED
Binary file
data/lib/live/page.rb CHANGED
@@ -26,6 +26,8 @@ require_relative 'resolver'
26
26
  require 'async'
27
27
  require 'async/queue'
28
28
 
29
+ require 'protocol/websocket/json_message'
30
+
29
31
  module Live
30
32
  # Represents a connected client page with bound dynamic content areas.
31
33
  class Page
@@ -77,6 +79,21 @@ module Live
77
79
  end
78
80
  end
79
81
 
82
+ # Process a single incoming message from the network.
83
+ def process_message(message)
84
+ if id = message[:bind] and data = message[:data]
85
+ if element = self.resolve(id, data)
86
+ self.bind(element)
87
+ else
88
+ Console.logger.warn(self, "Could not resolve element:", message)
89
+ end
90
+ elsif id = message[:id]
91
+ self.handle(id, message[:event])
92
+ else
93
+ Console.logger.warn(self, "Unhandled message:", message)
94
+ end
95
+ end
96
+
80
97
  # Run the event handling loop with the given websocket connection.
81
98
  # @parameter connection [Async::WebSocket::Connection]
82
99
  def run(connection)
@@ -84,7 +101,7 @@ module Live
84
101
  while update = @updates.dequeue
85
102
  Console.logger.debug(self, "Sending update:", update)
86
103
 
87
- connection.write(update)
104
+ connection.write(::Protocol::WebSocket::JSONMessage.generate(update))
88
105
  connection.flush if @updates.empty?
89
106
  end
90
107
  end
@@ -92,14 +109,8 @@ module Live
92
109
  while message = connection.read
93
110
  Console.logger.debug(self, "Reading message:", message)
94
111
 
95
- if id = message[:bind] and data = message[:data]
96
- if element = self.resolve(id, data)
97
- self.bind(element)
98
- else
99
- Console.logger.warn(self, "Could not resolve element:", message)
100
- end
101
- elsif id = message[:id]
102
- self.handle(id, message[:event])
112
+ if json_message = ::Protocol::WebSocket::JSONMessage.wrap(message)
113
+ process_message(json_message.parse)
103
114
  else
104
115
  Console.logger.warn(self, "Unhandled message:", message)
105
116
  end
data/lib/live/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Live
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,31 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
14
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZ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53aWxs
30
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
31
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
32
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
33
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
34
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
35
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
36
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
37
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
+ -----END CERTIFICATE-----
40
+ date: 2022-08-22 00:00:00.000000000 Z
12
41
  dependencies:
13
42
  - !ruby/object:Gem::Dependency
14
- name: trenni
43
+ name: async-websocket
15
44
  requirement: !ruby/object:Gem::Requirement
16
45
  requirements:
17
- - - ">="
46
+ - - "~>"
18
47
  - !ruby/object:Gem::Version
19
- version: '0'
48
+ version: 0.22.0
20
49
  type: :runtime
21
50
  prerelease: false
22
51
  version_requirements: !ruby/object:Gem::Requirement
23
52
  requirements:
24
- - - ">="
53
+ - - "~>"
25
54
  - !ruby/object:Gem::Version
26
- version: '0'
55
+ version: 0.22.0
27
56
  - !ruby/object:Gem::Dependency
28
- name: async-websocket
57
+ name: trenni
29
58
  requirement: !ruby/object:Gem::Requirement
30
59
  requirements:
31
60
  - - ">="
@@ -125,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
154
  - !ruby/object:Gem::Version
126
155
  version: '0'
127
156
  requirements: []
128
- rubygems_version: 3.2.15
157
+ rubygems_version: 3.3.7
129
158
  signing_key:
130
159
  specification_version: 4
131
160
  summary: Live HTML tags updated via a WebSocket.
metadata.gz.sig ADDED
Binary file