Class: OpenAI::Realtime::Transports::AsyncWebSocket::Socket
- Inherits:
-
Object
- Object
- OpenAI::Realtime::Transports::AsyncWebSocket::Socket
- Defined in:
- lib/openai/helpers/realtime/transports/async_websocket.rb
Instance Method Summary collapse
- #abort ⇒ Object private
- #aborted? ⇒ Boolean private
- #close(code: 1000, reason: "") ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(connection, url:) ⇒ Socket
constructor
private
A new instance of Socket.
- #read ⇒ Object
- #write(message) ⇒ Object
Constructor Details
#initialize(connection, url:) ⇒ 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.
144 145 146 147 148 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 144 def initialize(connection, url:) @connection = connection @url = url @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.
170 171 172 173 174 175 176 177 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 170 def abort framer = @connection.framer framer.extend(AbortableFramer) framer.abort @aborted = true rescue StandardError => e raise OpenAI::Errors::RealtimeConnectionError.new(url: @url, cause: e) 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.
180 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 180 def aborted? = @aborted |
#close(code: 1000, reason: "") ⇒ Object
163 164 165 166 167 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 163 def close(code: 1000, reason: "") @connection.close(code, reason) rescue StandardError => e raise OpenAI::Errors::RealtimeConnectionError.new(url: @url, cause: e) end |
#closed? ⇒ Boolean
182 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 182 def closed? = @aborted || @connection.closed? |
#read ⇒ Object
150 151 152 153 154 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 150 def read @connection.read rescue StandardError => e raise OpenAI::Errors::RealtimeConnectionError.new(url: @url, cause: e) end |
#write(message) ⇒ Object
156 157 158 159 160 161 |
# File 'lib/openai/helpers/realtime/transports/async_websocket.rb', line 156 def write() @connection.write() @connection.flush rescue StandardError => e raise OpenAI::Errors::RealtimeConnectionError.new(url: @url, cause: e) end |