Class: Teien::Network

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::P::ObjectProtocol
Defined in:
lib/teien/core/network.rb

Direct Known Subclasses

ClientNetwork, ServerNetwork

Constant Summary collapse

@@connections =
Hash.new
@@event_router =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_router) ⇒ Network

Returns a new instance of Network.



9
10
11
12
# File 'lib/teien/core/network.rb', line 9

def initialize(event_router)
  puts "network initialize"
  @@event_router = event_router
end

Class Method Details

.add_dummy_connection(from) ⇒ Object



18
19
20
# File 'lib/teien/core/network.rb', line 18

def self.add_dummy_connection(from)
  @@connections[from] = RemoteInfo.new(from)
end

.connectionsObject



14
15
16
# File 'lib/teien/core/network.rb', line 14

def self.connections
  @@connections
end

.send_event_to_all(obj) ⇒ Object



25
26
27
28
29
# File 'lib/teien/core/network.rb', line 25

def self.send_event_to_all(obj)
  @@connections.each_value { |c|
    c.connection.send_object(obj) if c.connection
  }
end