Turned SimClient into a partial class (and added SimClient(Grid), so that grid mode specific code can be kept separate)

Fixed the ServiceManager project (added reference to System.Xml to its project in prebuil.xml)
This commit is contained in:
MW
2007-05-15 15:05:13 +00:00
parent f41e5343c5
commit db6427b6f4
8 changed files with 306 additions and 327 deletions

View File

@@ -50,7 +50,7 @@ namespace OpenSim
/// Handles new client connections
/// Constructor takes a single Packet and authenticates everything
/// </summary>
public class SimClient
public partial class SimClient
{
public LLUUID AgentID;
public LLUUID SessionID;
@@ -142,82 +142,6 @@ namespace OpenSim
this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
}
public void CrossSimBorder(LLVector3 avatarpos)
{ // VERY VERY BASIC
LLVector3 newpos = avatarpos;
uint neighbourx = this.m_regionData.RegionLocX;
uint neighboury = this.m_regionData.RegionLocY;
if (avatarpos.X < 0)
{
neighbourx -= 1;
newpos.X = 254;
}
if (avatarpos.X > 255)
{
neighbourx += 1;
newpos.X = 1;
}
if (avatarpos.Y < 0)
{
neighboury -= 1;
newpos.Y = 254;
}
if (avatarpos.Y > 255)
{
neighbourx += 1;
newpos.Y = 1;
}
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
Hashtable SimParams;
ArrayList SendParams;
XmlRpcRequest GridReq;
XmlRpcResponse GridResp;
foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
{
if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
{
SimParams = new Hashtable();
SimParams["firstname"] = this.ClientAvatar.firstname;
SimParams["lastname"] = this.ClientAvatar.lastname;
SimParams["circuit_code"] = this.CircuitCode.ToString();
SimParams["pos_x"] = newpos.X.ToString();
SimParams["pos_y"] = newpos.Y.ToString();
SimParams["pos_z"] = newpos.Z.ToString();
SendParams = new ArrayList();
SendParams.Add(SimParams);
GridReq = new XmlRpcRequest("agent_crossing", SendParams);
GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
NewSimPack.AgentData.AgentID = this.AgentID;
NewSimPack.AgentData.SessionID = this.SessionID;
NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
NewSimPack.Info.Position = newpos;
NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
byte[] byteIP = neighbourIP.GetAddressBytes();
NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
NewSimPack.RegionData.SimIP += (uint)byteIP[0];
NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
NewSimPack.RegionData.SeedCapability = new byte[0];
lock (PacketQueue)
{
ProcessOutPacket(NewSimPack);
DowngradeClient();
}
}
}
}
public void UpgradeClient()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"SimClient.cs:UpgradeClient() - upgrading child to full agent");
@@ -1227,51 +1151,5 @@ namespace OpenSim
//now should get other regions maps from gridserver
}
public void EnableNeighbours()
{
if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
{
Hashtable SimParams;
ArrayList SendParams;
XmlRpcRequest GridReq;
XmlRpcResponse GridResp;
List<Packet> enablePackets = new List<Packet>();
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)
{
this.OutPacket(enable);
}
enablePackets.Clear();
}
}
}
}