Module: Pepper::Connection::ClassMethods

Defined in:
lib/pepper/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



11
12
13
# File 'lib/pepper/connection.rb', line 11

def connection
  @connection
end

Instance Method Details

#connectObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pepper/connection.rb', line 24

def connect
  sock                    = TCPSocket.new( @server, @port )
  ssl_context             = OpenSSL::SSL::SSLContext.new
  ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
  self.connection         = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
  
  self.connection.sync_close
  self.connection.connect
  
  @parser = StreamParser.new self.connection
  @parser.get_frame
  
  self.connection
end

#settings=(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/pepper/connection.rb', line 13

def settings=(opts = {})
  @server   = opts[:server]
  @tag      = opts[:tag]
  @password = opts[:password]
  @port     = opts[:port] || 700
  @lang     = opts[:lang] || "en"
  
  @logged_in = false
  @parser    = nil
end

#write(xml) ⇒ Object



39
40
41
42
# File 'lib/pepper/connection.rb', line 39

def write(xml)
  (@parser && self.connection || self.connect).write(xml)
  @parser.get_frame
end