Module: Ronin::Support::Web::WebSocket::Mixin
- Included in:
 - Mixin
 
- Defined in:
 - lib/ronin/support/web/websocket/mixin.rb
 
Overview
Adds helper methods for working with WebSockets.
Instance Method Summary collapse
- 
  
    
      #websocket_accept(url, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Opens a WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
 - 
  
    
      #websocket_connect(url, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to a websocket.
 - 
  
    
      #websocket_connect_and_send(data, url, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the WebSocket and sends the data.
 - 
  
    
      #websocket_open?(url, ssl: {}, **kwargs)  ⇒ Boolean? 
    
    
  
  
  
  
  
  
  
  
  
    
Tests whether the WebSocket is open.
 - 
  
    
      #websocket_send(data, url, type: :text, ssl: {}, **kwargs)  ⇒ true 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the WebSocket, sends the data, and closes the connection.
 - 
  
    
      #websocket_server(url, ssl: {}, **kwargs) {|server| ... } ⇒ Server 
    
    
  
  
  
  
  
  
  
  
  
    
Starts a WebSocket server.
 - 
  
    
      #websocket_server_loop(url, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a new WebSocket server listening on a given host and port, accepting clients in a loop.
 - 
  
    
      #ws_accept(host, port = 80, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Opens a WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
 - 
  
    
      #ws_connect(host, port = 80, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to a WebSocket.
 - 
  
    
      #ws_connect_and_send(data, host, port = 80, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the WebSocket and sends the data.
 - 
  
    
      #ws_open?(host, port = 80, ssl: {}, **kwargs)  ⇒ Boolean? 
    
    
  
  
  
  
  
  
  
  
  
    
Tests whether the WebSocket is open.
 - 
  
    
      #ws_send(data, host, port = 80, type: :text, ssl: {}, **kwargs)  ⇒ true 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the WebSocket, sends the data, and closes the connection.
 - 
  
    
      #ws_server(host, port = 80, ssl: {}, **kwargs) {|server| ... } ⇒ Server 
    
    
  
  
  
  
  
  
  
  
  
    
Starts a WebSocket server.
 - 
  
    
      #ws_server_loop(host, port = 80, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a new WebSocket server listening on a given host and port, accepting clients in a loop.
 - 
  
    
      #wss_accept(host, port = 443, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Opens a SSL/TLS WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
 - 
  
    
      #wss_connect(host, port = 443, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to a SSL/TLS WebSocket.
 - 
  
    
      #wss_connect_and_send(data, host, port = 443, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the SSL/TLS WebSocket and sends the data.
 - 
  
    
      #wss_open?(host, port = 443, ssl: {}, **kwargs)  ⇒ Boolean? 
    
    
  
  
  
  
  
  
  
  
  
    
Tests whether the SSL/TLS WebSocket is open.
 - 
  
    
      #wss_send(data, host, port = 443, type: :text, ssl: {}, **kwargs)  ⇒ true 
    
    
  
  
  
  
  
  
  
  
  
    
Connects to the SSL/TLS WebSocket, sends the data, and closes the connection.
 - 
  
    
      #wss_server(host, port = 443, ssl: {}, **kwargs) {|server| ... } ⇒ Server 
    
    
  
  
  
  
  
  
  
  
  
    
Starts a SSL/TLS WebSocket server.
 - 
  
    
      #wss_server_loop(host, port = 443, ssl: {}, **kwargs) {|client| ... } ⇒ nil 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a new SSL/TLS WebSocket server listening on a given host and port, accepting clients in a loop.
 
Instance Method Details
#websocket_accept(url, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Opens a WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
      324 325 326  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 324 def websocket_accept(url, ssl: {}, **kwargs,&block) WebSocket.accept(url, ssl: ssl, **kwargs,&block) end  | 
  
#websocket_connect(url, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to a websocket.
      138 139 140  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 138 def websocket_connect(url, ssl: {}, **kwargs, &block) WebSocket.connect(url, ssl: ssl, **kwargs, &block) end  | 
  
#websocket_connect_and_send(data, url, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to the WebSocket and sends the data.
      178 179 180  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 178 def websocket_connect_and_send(data,url, type: :text, ssl: {}, **kwargs,&block) WebSocket.connect_and_send(data,url, type: type, ssl: ssl, **kwargs,&block) end  | 
  
#websocket_open?(url, ssl: {}, **kwargs) ⇒ Boolean?
Tests whether the WebSocket is open.
      95 96 97  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 95 def websocket_open?(url, ssl: {}, **kwargs) WebSocket.open?(url, ssl: ssl, **kwargs) end  | 
  
#websocket_send(data, url, type: :text, ssl: {}, **kwargs) ⇒ true
Connects to the WebSocket, sends the data, and closes the connection.
      210 211 212  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 210 def websocket_send(data,url, type: :text, ssl: {}, **kwargs) WebSocket.send(data,url, type: type, ssl: ssl, **kwargs) end  | 
  
#websocket_server(url, ssl: {}, **kwargs) {|server| ... } ⇒ Server
Starts a WebSocket server.
      256 257 258  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 256 def websocket_server(url, ssl: {}, **kwargs, &block) WebSocket.server(url, ssl: ssl, **kwargs, &block) end  | 
  
#websocket_server_loop(url, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Creates a new WebSocket server listening on a given host and port, accepting clients in a loop.
      290 291 292  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 290 def websocket_server_loop(url, ssl: {}, **kwargs,&block) WebSocket.server_loop(url, ssl: ssl, **kwargs,&block) end  | 
  
#ws_accept(host, port = 80, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Opens a WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
      762 763 764 765 766  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 762 def ws_accept(host,port=80, ssl: {}, **kwargs,&block) uri = URI::WS.build(host: host, port: port) WebSocket.accept(uri, ssl: ssl, **kwargs,&block) end  | 
  
#ws_connect(host, port = 80, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to a WebSocket.
      402 403 404 405 406  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 402 def ws_connect(host,port=80, ssl: {}, **kwargs,&block) uri = URI::WS.build(host: host, port: port) WebSocket.connect(uri, ssl: ssl, **kwargs, &block) end  | 
  
#ws_connect_and_send(data, host, port = 80, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to the WebSocket and sends the data.
      447 448 449 450 451  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 447 def ws_connect_and_send(data,host,port=80, type: :text, ssl: {}, **kwargs,&block) uri = URI::WS.build(host: host, port: port) WebSocket.connect_and_send(data,uri, type: type, ssl: ssl, **kwargs,&block) end  | 
  
#ws_open?(host, port = 80, ssl: {}, **kwargs) ⇒ Boolean?
Tests whether the WebSocket is open.
      354 355 356 357 358  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 354 def ws_open?(host,port=80, ssl: {}, **kwargs) uri = URI::WS.build(host: host, port: port) WebSocket.open?(uri, ssl: ssl, **kwargs) end  | 
  
#ws_send(data, host, port = 80, type: :text, ssl: {}, **kwargs) ⇒ true
Connects to the WebSocket, sends the data, and closes the connection.
      484 485 486 487 488  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 484 def ws_send(data,host,port=80, type: :text, ssl: {}, **kwargs) uri = URI::WS.build(host: host, port: port) WebSocket.send(data,uri, type: type, ssl: ssl, **kwargs) end  | 
  
#ws_server(host, port = 80, ssl: {}, **kwargs) {|server| ... } ⇒ Server
Starts a WebSocket server.
      684 685 686 687 688  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 684 def ws_server(host,port=80, ssl: {}, **kwargs,&block) uri = URI::WS.build(host: host, port: port) WebSocket.server(uri, ssl: ssl, **kwargs,&block) end  | 
  
#ws_server_loop(host, port = 80, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Creates a new WebSocket server listening on a given host and port, accepting clients in a loop.
      723 724 725 726 727  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 723 def ws_server_loop(host,port=80, ssl: {}, **kwargs,&block) uri = URI::WS.build(host: host, port: port) WebSocket.server_loop(uri, ssl: ssl, **kwargs,&block) end  | 
  
#wss_accept(host, port = 443, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Opens a SSL/TLS WebSocket server, accepts a single connection, yields it to the given block, then closes both the connection and the server.
      879 880 881 882 883  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 879 def wss_accept(host,port=443, ssl: {}, **kwargs,&block) uri = URI::WSS.build(host: host, port: port) WebSocket.accept(uri, ssl: ssl, **kwargs,&block) end  | 
  
#wss_connect(host, port = 443, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to a SSL/TLS WebSocket.
      564 565 566 567 568  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 564 def wss_connect(host,port=443, ssl: {}, **kwargs,&block) uri = URI::WSS.build(host: host, port: port) WebSocket.connect(uri, ssl: ssl, **kwargs, &block) end  | 
  
#wss_connect_and_send(data, host, port = 443, type: :text, ssl: {}, **kwargs) {|websocket| ... } ⇒ Client
Connects to the SSL/TLS WebSocket and sends the data.
      609 610 611 612 613  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 609 def wss_connect_and_send(data,host,port=443, type: :text, ssl: {}, **kwargs,&block) uri = URI::WSS.build(host: host, port: port) WebSocket.connect_and_send(data,uri, type: type, ssl: ssl, **kwargs, &block) end  | 
  
#wss_open?(host, port = 443, ssl: {}, **kwargs) ⇒ Boolean?
Tests whether the SSL/TLS WebSocket is open.
      516 517 518 519 520  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 516 def wss_open?(host,port=443, ssl: {}, **kwargs) uri = URI::WSS.build(host: host, port: port) WebSocket.open?(uri, ssl: ssl, **kwargs) end  | 
  
#wss_send(data, host, port = 443, type: :text, ssl: {}, **kwargs) ⇒ true
Connects to the SSL/TLS WebSocket, sends the data, and closes the connection.
      646 647 648 649 650  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 646 def wss_send(data,host,port=443, type: :text, ssl: {}, **kwargs) uri = URI::WSS.build(host: host, port: port) WebSocket.send(data,uri, type: type, ssl: ssl, **kwargs) end  | 
  
#wss_server(host, port = 443, ssl: {}, **kwargs) {|server| ... } ⇒ Server
Starts a SSL/TLS WebSocket server.
      800 801 802 803 804  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 800 def wss_server(host,port=443, ssl: {}, **kwargs,&block) uri = URI::WSS.build(host: host, port: port) WebSocket.server(uri, ssl: ssl, **kwargs,&block) end  | 
  
#wss_server_loop(host, port = 443, ssl: {}, **kwargs) {|client| ... } ⇒ nil
Creates a new SSL/TLS WebSocket server listening on a given host and port, accepting clients in a loop.
      839 840 841 842 843  | 
    
      # File 'lib/ronin/support/web/websocket/mixin.rb', line 839 def wss_server_loop(host,port=443, ssl: {}, **kwargs,&block) uri = URI::WSS.build(host: host, port: port) WebSocket.server_loop(uri, ssl: ssl, **kwargs,&block) end  |