Class: Vertx::WebSocket
- Inherits:
-
Object
- Object
- Vertx::WebSocket
- Includes:
- ReadStream, WriteStream
- Defined in:
- src/main/api_shim/core/http.rb
Overview
Represents a WebSocket.
Instances of this class are created by an HttpClient instance when a client succeeds in a WebSocket handshake with a server.
Once an instance has been obtained it can be used to send or receive buffers of data from the connection,
a bit like a TCP socket.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (Object) binary_handler_id
When a Websocket is created it automatically registers an event handler with the system, the ID of that handler is given by #binary_handler_id.
-
- (Object) close
Close the WebSocket.
-
- (Object) close_handler(&hndlr)
Set a closed handler on the WebSocket.
-
- (Object) text_handler_id
When a Websocket is created it automatically registers an event handler with the system, the ID of that handler is given by #text_handler_id.
-
- (Object) write_binary_frame(buffer)
Write data to the WebSocket as a binary frame.
-
- (Object) write_text_frame(str)
Write data to the WebSocket as a text frame.
Methods included from ReadStream
#data_handler, #end_handler, #exception_handler, #pause, #resume
Methods included from WriteStream
#drain_handler, #exception_handler, #write, #write_queue_full?, #write_queue_max_size, #write_queue_max_size=
Instance Method Details
- (Object) binary_handler_id
When a Websocket is created it automatically registers an event handler with the system, the ID of that
handler is given by #binary_handler_id.
Given this ID, a different event loop can send a binary frame to that event handler using the event bus. This
allows you to write data to other WebSockets which are owned by different event loops.
816 817 818 |
# File 'src/main/api_shim/core/http.rb', line 816 def binary_handler_id @binary_handler_id end |
- (Object) close
Close the WebSocket
808 809 810 |
# File 'src/main/api_shim/core/http.rb', line 808 def close @j_del.close end |
- (Object) close_handler(&hndlr)
Set a closed handler on the WebSocket.
830 831 832 |
# File 'src/main/api_shim/core/http.rb', line 830 def close_handler(&hndlr) @close_handler = hndlr end |
- (Object) text_handler_id
When a Websocket is created it automatically registers an event handler with the system, the ID of that
handler is given by #text_handler_id.
Given this ID, a different event loop can send a text frame to that event handler using the event bus. This
allows you to write data to other WebSockets which are owned by different event loops.
824 825 826 |
# File 'src/main/api_shim/core/http.rb', line 824 def text_handler_id @text_handler_id end |
- (Object) write_binary_frame(buffer)
Write data to the WebSocket as a binary frame
795 796 797 798 |
# File 'src/main/api_shim/core/http.rb', line 795 def write_binary_frame(buffer) @j_del.writeBinaryFrame(buffer._to_java_buffer) self end |
- (Object) write_text_frame(str)
Write data to the WebSocket as a text frame
802 803 804 805 |
# File 'src/main/api_shim/core/http.rb', line 802 def write_text_frame(str) @j_del.writeTextFrame(str) self end |