Method: LibSL::Simulator#initialize

Defined in:
lib/network.rb

#initialize(client, ip, port, circuit_code, session_id, agent_id) ⇒ Simulator

Manages the connection to a Simulator

Parameters:

  • client (Client)

    The client

  • ip (String)

    The simulator ip

  • port (Integer)

    The simulator port

  • circuit_code (LLU32)

    The circuit code

  • session_id (LLUUID)

    The current session id

  • agent_id (LLUUID)

    The id of the agent that logs into the sim



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/network.rb', line 38

def initialize(client, ip, port, circuit_code, session_id, agent_id)
	@client = client
	@connected = false
	@sim_ip = ip
	@sim_port = port
	@circuit_code = circuit_code
	@session_id = session_id
	@agent_id = agent_id
	@sequence_number = 0
	@connection = EventMachine::open_datagram_socket "0.0.0.0", 0, CircuitHandler, self
	@packets_sent_reliably = {}
	@packets_received_reliably = {}
	
	# Start ack timers
	@ack_timer = EventMachine::add_periodic_timer(1) do
		send_acks
	end
	@resend_timer = EventMachine::add_periodic_timer 2 do
		@packets_sent_reliably.each { |sequence_num, packet|
			if packet.resent_count < 3
				send_packet(packet, false, true)
			else
				@packets_sent_reliably.delete sequence_num
			end
		}
	end
end