From 582b0c134105b37e17ad8d7f3ecef2111e1a4903 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Mon, 8 Jul 2024 17:07:50 +0400 Subject: [PATCH] further fixes for websockets --- lib/landline/extensions/websocket.rb | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/landline/extensions/websocket.rb b/lib/landline/extensions/websocket.rb index c497958..84f44d1 100644 --- a/lib/landline/extensions/websocket.rb +++ b/lib/landline/extensions/websocket.rb @@ -24,28 +24,6 @@ module Landline @__listeners[event]&.delete(listener) end - # Await for an event - # @param event [Symbol, Array] event or array of events to wait for - # @return [Array] - # @sg-ignore - def await(event) - blocking = true - output = nil - listener = proc do |*data| - output = data - blocking = false - end - if event.is_a? Array - event.each { |x| on(x, &listener) } - else - on(event, &listener) - end - while blocking; end - return output[0] if output.is_a? Array and output.length == 1 - - output - end - private # Trigger the queue clearing process @@ -115,6 +93,7 @@ module Landline rescue Errno::EPIPE => e _emit :error, e close + nil end # Read data from socket synchronously @@ -225,6 +204,7 @@ module Landline rescue Errno::ECONNRESET => e _emit :error, e close + nil end # Receive data through websocket asynchronously @@ -238,6 +218,7 @@ module Landline rescue Errno::ECONNRESET => e _emit :error, e close + nil end end end