From 51581dba75ef438d71679ac6a81ef7938f41fbc0 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 17 May 2007 12:47:45 +0000 Subject: [PATCH] * refactored a bit and added error msg --- OpenSim.RegionServer/SimClient.Grid.cs | 76 +++++++++++++++----------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/OpenSim.RegionServer/SimClient.Grid.cs b/OpenSim.RegionServer/SimClient.Grid.cs index b0d59cc11c..3ae419aff8 100644 --- a/OpenSim.RegionServer/SimClient.Grid.cs +++ b/OpenSim.RegionServer/SimClient.Grid.cs @@ -30,40 +30,54 @@ namespace OpenSim XmlRpcRequest GridReq; XmlRpcResponse GridResp; List enablePackets = new List(); - foreach (Hashtable neighbour in ((RemoteGridBase)this.m_gridServer).neighbours) - { - Console.WriteLine("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"]); - SimParams = new Hashtable(); - SimParams["session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SessionID.ToString(); - SimParams["secure_session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SecureSessionID.ToString(); - SimParams["firstname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].firstname; - SimParams["lastname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].lastname; - SimParams["agent_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].AgentID.ToString(); - SimParams["circuit_code"] = (Int32)this.CircuitCode; - SimParams["child_agent"] = "1"; - SendParams = new ArrayList(); - SendParams.Add(SimParams); - GridReq = new XmlRpcRequest("expect_user", SendParams); - GridResp = GridReq.Send("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"], 3000); - EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); - enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); - enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256)); - System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)neighbour["sim_ip"]); - byte[] byteIP = neighbourIP.GetAddressBytes(); - enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; - enablesimpacket.SimulatorInfo.Port = (ushort)Convert.ToInt32(neighbour["sim_port"]); - enablePackets.Add(enablesimpacket); - } - Thread.Sleep(3000); - foreach (Packet enable in enablePackets) + RemoteGridBase gridServer = (RemoteGridBase)this.m_gridServer; + + Dictionary agentCircuits = gridServer.agentcircuits; + AgentCircuitData agentCircuit; + + if (agentCircuits.TryGetValue(CircuitCode, out agentCircuit)) { - this.OutPacket(enable); + + foreach (Hashtable neighbour in gridServer.neighbours) + { + Console.WriteLine("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"]); + SimParams = new Hashtable(); + SimParams["session_id"] = agentCircuit.SessionID.ToString(); + SimParams["secure_session_id"] = agentCircuit.SecureSessionID.ToString(); + SimParams["firstname"] = agentCircuit.firstname; + SimParams["lastname"] = agentCircuit.lastname; + SimParams["agent_id"] = agentCircuit.AgentID.ToString(); + SimParams["circuit_code"] = (Int32)this.CircuitCode; + SimParams["child_agent"] = "1"; + SendParams = new ArrayList(); + SendParams.Add(SimParams); + + GridReq = new XmlRpcRequest("expect_user", SendParams); + GridResp = GridReq.Send("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"], 3000); + EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); + enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); + enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256)); + System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)neighbour["sim_ip"]); + byte[] byteIP = neighbourIP.GetAddressBytes(); + enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; + enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; + enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; + enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; + enablesimpacket.SimulatorInfo.Port = (ushort)Convert.ToInt32(neighbour["sim_port"]); + enablePackets.Add(enablesimpacket); + } + Thread.Sleep(3000); + foreach (Packet enable in enablePackets) + { + this.OutPacket(enable); + } + enablePackets.Clear(); } - enablePackets.Clear(); + } + else + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "SimClient.cs: Couldn't find AgentCircuit for CircuitCode {0}.", CircuitCode ); } }