Class: Tortard::Bridge
- Inherits:
-
Object
- Object
- Tortard::Bridge
- Defined in:
- lib/tortard/bridge.rb,
lib/tortard/bridge/client.rb,
lib/tortard/bridge/connection.rb
Defined Under Namespace
Classes: Client, Connection
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(proxy, from, to, ssl = :none) ⇒ Bridge
constructor
A new instance of Bridge.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(proxy, from, to, ssl = :none) ⇒ Bridge
Returns a new instance of Bridge.
24 25 26 27 28 29 30 31 |
# File 'lib/tortard/bridge.rb', line 24 def initialize (proxy, from, to, ssl = :none) @proxy = proxy @from = from @to = to @ssl = ssl @clients = [] end |
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
22 23 24 |
# File 'lib/tortard/bridge.rb', line 22 def clients @clients end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
22 23 24 |
# File 'lib/tortard/bridge.rb', line 22 def from @from end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
22 23 24 |
# File 'lib/tortard/bridge.rb', line 22 def proxy @proxy end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
22 23 24 |
# File 'lib/tortard/bridge.rb', line 22 def ssl @ssl end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
22 23 24 |
# File 'lib/tortard/bridge.rb', line 22 def to @to end |
Instance Method Details
#start ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/tortard/bridge.rb', line 33 def start @signature = EM.start_server to.host, to.port, Client do |c| c.bridge = self c.connect @clients << c end end |
#stop ⇒ Object
42 43 44 45 46 |
# File 'lib/tortard/bridge.rb', line 42 def stop @clients.each(&:disconnect) EM.stop_server @signature end |