Class: LibSL::CircuitHandler

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/network.rb

Instance Method Summary collapse

Constructor Details

#initialize(sim) ⇒ CircuitHandler

Handles the connection (or circuit in SL)

Parameters:

  • sim (Simulator)

    The simulator this connection is managed for



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

def initialize(sim)
	@sim = sim
end

Instance Method Details

#receive_data(data) ⇒ Object

Called when data is received from the circuit

Parameters:

  • data (String)

    The received data



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

def receive_data(data)
	packet = Packet::decode(data)
	@sim.packet_received packet
end

#unbindObject



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

def unbind
	EventManager::fire_event :disconnected, @sim
end