Class: OpenAI::WebSocket::AsyncWebSocketTransport::Socket Private
- Inherits:
-
Object
- Object
- OpenAI::WebSocket::AsyncWebSocketTransport::Socket
- Defined in:
- lib/openai/helpers/websocket/async_websocket_transport.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Method Summary collapse
- #abort ⇒ Object private
- #aborted? ⇒ Boolean private
- #close(code: 1000, reason: "") ⇒ Object private
- #closed? ⇒ Boolean private
-
#initialize(connection, url:, error_factory:) ⇒ Socket
constructor
private
A new instance of Socket.
- #read ⇒ Object private
- #write(message) ⇒ Object private
Constructor Details
#initialize(connection, url:, error_factory:) ⇒ Socket
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Socket.
163 164 165 166 167 168 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 163 def initialize(connection, url:, error_factory:) @connection = connection @url = url @error_factory = error_factory @aborted = false end |
Instance Method Details
#abort ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
195 196 197 198 199 200 201 202 203 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 195 def abort framer = @connection.framer framer.extend(AbortableFramer) unless framer.respond_to?(:abort) framer.abort @aborted = true rescue StandardError => e error = @error_factory.call(url: @url, cause: e) raise error, cause: nil end |
#aborted? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
206 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 206 def aborted? = @aborted |
#close(code: 1000, reason: "") ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
187 188 189 190 191 192 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 187 def close(code: 1000, reason: "") @connection.close(code, reason) rescue StandardError => e error = @error_factory.call(url: @url, cause: e) raise error, cause: nil end |
#closed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
208 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 208 def closed? = @aborted || @connection.closed? |
#read ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
170 171 172 173 174 175 176 177 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 170 def read @connection.read rescue StandardError => e error = @error_factory.call(url: @url, cause: e) # The factory retains explicit diagnostics; do not render them as a # native exception chain, which can include payloads or credentials. raise error, cause: nil end |
#write(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
179 180 181 182 183 184 185 |
# File 'lib/openai/helpers/websocket/async_websocket_transport.rb', line 179 def write() @connection.write() @connection.flush rescue StandardError => e error = @error_factory.call(url: @url, cause: e) raise error, cause: nil end |