Class: Tortard::Bridge

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientsObject (readonly)

Returns the value of attribute clients.



22
23
24
# File 'lib/tortard/bridge.rb', line 22

def clients
  @clients
end

#fromObject (readonly)

Returns the value of attribute from.



22
23
24
# File 'lib/tortard/bridge.rb', line 22

def from
  @from
end

#proxyObject (readonly)

Returns the value of attribute proxy.



22
23
24
# File 'lib/tortard/bridge.rb', line 22

def proxy
  @proxy
end

#sslObject (readonly)

Returns the value of attribute ssl.



22
23
24
# File 'lib/tortard/bridge.rb', line 22

def ssl
  @ssl
end

#toObject (readonly)

Returns the value of attribute to.



22
23
24
# File 'lib/tortard/bridge.rb', line 22

def to
  @to
end

Instance Method Details

#startObject



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

#stopObject



42
43
44
45
46
# File 'lib/tortard/bridge.rb', line 42

def stop
	@clients.each(&:disconnect)

	EM.stop_server @signature
end