From f8a2c58c229935dbc98c0d18e874fd0251d0a0d5 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 3 Jul 2024 18:11:57 +0900 Subject: [PATCH] Drop usage of JSONMessage. --- lib/live/page.rb | 13 ++++--------- live.gemspec | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/live/page.rb b/lib/live/page.rb index e14d8b7..ee43162 100644 --- a/lib/live/page.rb +++ b/lib/live/page.rb @@ -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. @@ -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 diff --git a/live.gemspec b/live.gemspec index e5dbbdb..b4e6617 100644 --- a/live.gemspec +++ b/live.gemspec @@ -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