Class: Whatup::Client::Client
- Inherits:
-
Object
- Object
- Whatup::Client::Client
- Includes:
- Thor::Shell
- Defined in:
- lib/whatup/client/client.rb
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(ip:, port:) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(ip:, port:) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/whatup/client/client.rb', line 10 def initialize ip:, port: @dest = { ip: ip, port: port, address: "#{@ip}:#{@port}" } end |
Instance Method Details
#connect ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/whatup/client/client.rb', line 18 def connect say "Connecting to #{@dest[:ip]}:#{@dest[:port]} ..." @socket = TCPSocket.open @dest[:ip], @dest[:port] puts 'Please enter your username to establish a connection...' @request = request! @response = listen! [@request, @response].each &:join rescue SignalException say 'Exiting ...', :red exit end |