From 3e01863869346dda19ce25c532a763cf683fc55c 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 | 11 +++-------- live.gemspec | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/live/page.rb b/lib/live/page.rb index e14d8b7..4ee2cee 100644 --- a/lib/live/page.rb +++ b/lib/live/page.rb @@ -9,7 +9,7 @@ require 'async' require 'async/queue' -require 'protocol/websocket/json_message' +require 'protocol/websocket' module Live # Represents a connected client page with bound dynamic content areas. @@ -95,19 +95,14 @@ def run(connection) while update = @updates.dequeue Console.debug(self, "Sending update:", update) - connection.write(::Protocol::WebSocket::JSONMessage.generate(update)) + connection.write(::Protocol::WebSocket::Message.generate(update)) 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..95a9992 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.26" spec.add_dependency "xrb" end