Class: Fishbowl::Connection
- Inherits:
-
Object
- Object
- Fishbowl::Connection
- Includes:
- Singleton
- Defined in:
- lib/fishbowl/connection.rb
Class Method Summary collapse
- .close ⇒ Object
- .connect ⇒ Object
- .host ⇒ Object
- .login ⇒ Object
- .password ⇒ Object
- .port ⇒ Object
- .send(request, expected_response = 'FbiMsgsRs') ⇒ Object
- .username ⇒ Object
Class Method Details
.close ⇒ Object
58 59 60 61 |
# File 'lib/fishbowl/connection.rb', line 58 def self.close @connection.close @connection = nil end |
.connect ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fishbowl/connection.rb', line 7 def self.connect() raise Fishbowl::Errors::MissingHost if Fishbowl.configuration.host.nil? @host = Fishbowl.configuration.host @port = Fishbowl.configuration.port.nil? ? 28192 : Fishbowl.configuration.port @connection = TCPSocket.new @host, @port self.instance end |
.host ⇒ Object
34 35 36 |
# File 'lib/fishbowl/connection.rb', line 34 def self.host @host end |
.login ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fishbowl/connection.rb', line 18 def self.login() raise Fishbowl::Errors::ConnectionNotEstablished if @connection.nil? raise Fishbowl::Errors::MissingUsername if Fishbowl.configuration.host.nil? raise Fishbowl::Errors::MissingPassword if Fishbowl.configuration.host.nil? @username = Fishbowl.configuration.username @password = Fishbowl.configuration.password code, _ = Fishbowl::Objects::BaseObject.new.send_request(login_request) Fishbowl::Errors.confirm_success_or_raise(code) raise "Login failed" unless code.eql? "1000" self.instance end |
.password ⇒ Object
46 47 48 |
# File 'lib/fishbowl/connection.rb', line 46 def self.password @password end |
.port ⇒ Object
38 39 40 |
# File 'lib/fishbowl/connection.rb', line 38 def self.port @port end |
.send(request, expected_response = 'FbiMsgsRs') ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/fishbowl/connection.rb', line 50 def self.send(request, expected_response = 'FbiMsgsRs') puts 'opening connection...' if Fishbowl.configuration.debug.eql? true puts request if Fishbowl.configuration.debug.eql? true puts 'waiting for response...' if Fishbowl.configuration.debug.eql? true write(request) get_response(expected_response) end |
.username ⇒ Object
42 43 44 |
# File 'lib/fishbowl/connection.rb', line 42 def self.username @username end |