Skip to content

Commit

Permalink
Drop usage of JSONMessage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 3, 2024
1 parent 3c7f964 commit f8a2c58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions lib/live/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
require 'async'
require 'async/queue'

require 'protocol/websocket/json_message'
require 'protocol/websocket'
require 'protocol/websocket/message'

module Live
# Represents a connected client page with bound dynamic content areas.
Expand Down Expand Up @@ -94,20 +95,14 @@ def run(connection)
queue_task = Async do
while update = @updates.dequeue
Console.debug(self, "Sending update:", update)

connection.write(::Protocol::WebSocket::JSONMessage.generate(update))
::Protocol::WebSocket::TextMessage.generate(update).send(connection)
connection.flush if @updates.empty?
end
end

while message = connection.read
Console.debug(self, "Reading message:", message)

if json_message = ::Protocol::WebSocket::JSONMessage.wrap(message)
process_message(json_message.parse)
else
Console.warn(self, "Unhandled message:", message)
end
process_message(message.parse)
end
ensure
self.close
Expand Down
2 changes: 1 addition & 1 deletion live.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 3.1"

spec.add_dependency "async-websocket", "~> 0.23"
spec.add_dependency "async-websocket", "~> 0.27"
spec.add_dependency "xrb"
end

0 comments on commit f8a2c58

Please sign in to comment.