Class: Tortard::Bridge::Client
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Tortard::Bridge::Client
- Defined in:
- lib/tortard/bridge/client.rb
Instance Attribute Summary collapse
-
#bridge ⇒ Object
Returns the value of attribute bridge.
Instance Method Summary collapse
- #connect ⇒ Object
- #connected ⇒ Object
- #disconnect ⇒ Object
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #received(data) ⇒ Object
- #unbind ⇒ Object
Instance Attribute Details
#bridge ⇒ Object
Returns the value of attribute bridge.
16 17 18 |
# File 'lib/tortard/bridge/client.rb', line 16 def bridge @bridge end |
Instance Method Details
#connect ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tortard/bridge/client.rb', line 22 def connect if bridge.ssl == :both || bridge.ssl == :external start_tls end EM.connect bridge.proxy.host, bridge.proxy.port, Connection do |c| c.client = self c.bridge = bridge @connection = c end end |
#connected ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/tortard/bridge/client.rb', line 47 def connected Tortard.log "connected to #{bridge.from}" buffer, @buffer = @buffer, nil buffer.each {|data| @connection.send_data data } end |
#disconnect ⇒ Object
43 44 45 |
# File 'lib/tortard/bridge/client.rb', line 43 def disconnect close_connection_after_writing end |
#post_init ⇒ Object
18 19 20 |
# File 'lib/tortard/bridge/client.rb', line 18 def post_init @buffer = [] end |
#receive_data(data) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/tortard/bridge/client.rb', line 35 def receive_data (data) if @buffer @buffer << data else @connection.send_data data end end |
#received(data) ⇒ Object
57 58 59 |
# File 'lib/tortard/bridge/client.rb', line 57 def received (data) send_data data end |
#unbind ⇒ Object
61 62 63 |
# File 'lib/tortard/bridge/client.rb', line 61 def unbind @connection.close_connection_after_writing if @connection end |