From 250254d2df5af5b9e267e8e701ebe62a3dfb7e85 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Mon, 8 Jul 2024 18:26:45 +0400 Subject: [PATCH] Added ability to IO.select websockets --- examples/websockets.ru | 1 + lib/landline/extensions/websocket.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/examples/websockets.ru b/examples/websockets.ru index b74f93f..72a1524 100644 --- a/examples/websockets.ru +++ b/examples/websockets.ru @@ -13,6 +13,7 @@ class Test < Landline::App puts "Client closed read connection" end socket.write("Hi!") + puts IO.select([socket]).inspect while (response = socket.read) if response puts "Client wrote: #{response.inspect}" diff --git a/lib/landline/extensions/websocket.rb b/lib/landline/extensions/websocket.rb index 84f44d1..4d035bf 100644 --- a/lib/landline/extensions/websocket.rb +++ b/lib/landline/extensions/websocket.rb @@ -171,6 +171,12 @@ module Landline close_write if @writable end + # Obtain internal IO object + # @return [IO] + def to_io + io + end + attr_reader :io, :readable, :writable private