live 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/live/element.rb +10 -2
- data/lib/live/page.rb +16 -19
- data/lib/live/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b389272cf70f88ade8e987e6df962c0e73761d738d7fc15e29134a6d3677f072
|
4
|
+
data.tar.gz: adebf021e1a94bed6fd09a4c90364f3176873fcbfb0b691005262a7095768927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f36c200788c094e7662f14dad854db15b5bfe2e04c96e4bf546e2821be91eef549eb574a872476db632e2a6d00cbbe3e3670954756d5b801364d06cfa627809
|
7
|
+
data.tar.gz: ac325892c144ae36d6417990f76271016782cb196a8cbb7d59645a14a4868804bdd2f61a813de2cff14a8053912115bb1e64961a0ea937023a7ea0ff04d6848e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/live/element.rb
CHANGED
@@ -7,6 +7,9 @@ require 'json'
|
|
7
7
|
require 'securerandom'
|
8
8
|
|
9
9
|
module Live
|
10
|
+
class PageError < RuntimeError
|
11
|
+
end
|
12
|
+
|
10
13
|
# Represents a single dynamic content area on the page.
|
11
14
|
class Element
|
12
15
|
def self.unique_id
|
@@ -66,8 +69,13 @@ module Live
|
|
66
69
|
# @parameter method [Symbol] The name of the remote functio to invoke.
|
67
70
|
# @parameter arguments [Array]
|
68
71
|
def rpc(*arguments)
|
69
|
-
|
70
|
-
|
72
|
+
if @page
|
73
|
+
# This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:
|
74
|
+
@page.updates.enqueue(arguments)
|
75
|
+
else
|
76
|
+
# This is a programming error, as it probably means the element is still part of the logic of the server side (e.g. async loop), but it is not bound to a page, so there is nothing to update/access/rpc.
|
77
|
+
raise PageError, "Element is not bound to a page, make sure to implement #close!"
|
78
|
+
end
|
71
79
|
end
|
72
80
|
end
|
73
81
|
end
|
data/lib/live/page.rb
CHANGED
@@ -9,7 +9,8 @@ require_relative 'resolver'
|
|
9
9
|
require 'async'
|
10
10
|
require 'async/queue'
|
11
11
|
|
12
|
-
require 'protocol/websocket
|
12
|
+
require 'protocol/websocket'
|
13
|
+
require 'protocol/websocket/message'
|
13
14
|
|
14
15
|
module Live
|
15
16
|
# Represents a connected client page with bound dynamic content areas.
|
@@ -91,27 +92,23 @@ module Live
|
|
91
92
|
# Run the event handling loop with the given websocket connection.
|
92
93
|
# @parameter connection [Async::WebSocket::Connection]
|
93
94
|
def run(connection)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
Sync do |task|
|
96
|
+
queue_task = task.async do
|
97
|
+
while update = @updates.dequeue
|
98
|
+
Console.debug(self, "Sending update:", update)
|
99
|
+
::Protocol::WebSocket::TextMessage.generate(update).send(connection)
|
100
|
+
connection.flush if @updates.empty?
|
101
|
+
end
|
100
102
|
end
|
101
|
-
end
|
102
|
-
|
103
|
-
while message = connection.read
|
104
|
-
Console.debug(self, "Reading message:", message)
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
Console.warn(self, "Unhandled message:", message)
|
104
|
+
while message = connection.read
|
105
|
+
Console.debug(self, "Reading message:", message)
|
106
|
+
process_message(message.parse)
|
110
107
|
end
|
108
|
+
ensure
|
109
|
+
self.close
|
110
|
+
queue_task&.stop
|
111
111
|
end
|
112
|
-
ensure
|
113
|
-
self.close
|
114
|
-
queue_task&.stop
|
115
112
|
end
|
116
113
|
end
|
117
|
-
end
|
114
|
+
end
|
data/lib/live/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: live
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-
|
41
|
+
date: 2024-07-03 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: async-websocket
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0.
|
49
|
+
version: '0.27'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '0.
|
56
|
+
version: '0.27'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: xrb
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.5.
|
106
|
+
rubygems_version: 3.5.11
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Live HTML tags updated via a WebSocket.
|
metadata.gz.sig
CHANGED
Binary file
|