aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/SimClient(Grid).cs
diff options
context:
space:
mode:
authorMW2007-05-15 15:05:13 +0000
committerMW2007-05-15 15:05:13 +0000
commitdb6427b6f4709d86c5bf1e4711ff2be0f65e5875 (patch)
treeea9d6f366436594f543c1d5b50c522dcfdb3b5e4 /OpenSim.RegionServer/SimClient(Grid).cs
parentupdated Build/project files to include the new projects and new files. (diff)
downloadopensim-SC_OLD-db6427b6f4709d86c5bf1e4711ff2be0f65e5875.zip
opensim-SC_OLD-db6427b6f4709d86c5bf1e4711ff2be0f65e5875.tar.gz
opensim-SC_OLD-db6427b6f4709d86c5bf1e4711ff2be0f65e5875.tar.bz2
opensim-SC_OLD-db6427b6f4709d86c5bf1e4711ff2be0f65e5875.tar.xz
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)
Diffstat (limited to 'OpenSim.RegionServer/SimClient(Grid).cs')
-rw-r--r--OpenSim.RegionServer/SimClient(Grid).cs146
1 files changed, 146 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/SimClient(Grid).cs b/OpenSim.RegionServer/SimClient(Grid).cs
new file mode 100644
index 0000000..b0d59cc
--- /dev/null
+++ b/OpenSim.RegionServer/SimClient(Grid).cs
@@ -0,0 +1,146 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using Nwc.XmlRpc;
7using System.Net;
8using System.Net.Sockets;
9using System.IO;
10using System.Threading;
11using System.Timers;
12using OpenSim.Framework.Interfaces;
13using OpenSim.Framework.Types;
14using OpenSim.Framework.Inventory;
15using OpenSim.Framework.Utilities;
16using OpenSim.world;
17using OpenSim.Assets;
18
19namespace OpenSim
20{
21 public partial class SimClient
22 {
23
24 public void EnableNeighbours()
25 {
26 if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
27 {
28 Hashtable SimParams;
29 ArrayList SendParams;
30 XmlRpcRequest GridReq;
31 XmlRpcResponse GridResp;
32 List<Packet> enablePackets = new List<Packet>();
33 foreach (Hashtable neighbour in ((RemoteGridBase)this.m_gridServer).neighbours)
34 {
35 Console.WriteLine("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"]);
36 SimParams = new Hashtable();
37 SimParams["session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SessionID.ToString();
38 SimParams["secure_session_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].SecureSessionID.ToString();
39 SimParams["firstname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].firstname;
40 SimParams["lastname"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].lastname;
41 SimParams["agent_id"] = ((RemoteGridBase)this.m_gridServer).agentcircuits[CircuitCode].AgentID.ToString();
42 SimParams["circuit_code"] = (Int32)this.CircuitCode;
43 SimParams["child_agent"] = "1";
44 SendParams = new ArrayList();
45 SendParams.Add(SimParams);
46
47 GridReq = new XmlRpcRequest("expect_user", SendParams);
48 GridResp = GridReq.Send("http://" + neighbour["sim_ip"] + ":" + neighbour["sim_port"], 3000);
49 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
50 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
51 enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
52 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)neighbour["sim_ip"]);
53 byte[] byteIP = neighbourIP.GetAddressBytes();
54 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
55 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
56 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
57 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
58 enablesimpacket.SimulatorInfo.Port = (ushort)Convert.ToInt32(neighbour["sim_port"]);
59 enablePackets.Add(enablesimpacket);
60 }
61 Thread.Sleep(3000);
62 foreach (Packet enable in enablePackets)
63 {
64 this.OutPacket(enable);
65 }
66 enablePackets.Clear();
67 }
68 }
69
70 public void CrossSimBorder(LLVector3 avatarpos)
71 { // VERY VERY BASIC
72
73 LLVector3 newpos = avatarpos;
74 uint neighbourx = this.m_regionData.RegionLocX;
75 uint neighboury = this.m_regionData.RegionLocY;
76
77 if (avatarpos.X < 0)
78 {
79 neighbourx -= 1;
80 newpos.X = 254;
81 }
82 if (avatarpos.X > 255)
83 {
84 neighbourx += 1;
85 newpos.X = 1;
86 }
87 if (avatarpos.Y < 0)
88 {
89 neighboury -= 1;
90 newpos.Y = 254;
91 }
92 if (avatarpos.Y > 255)
93 {
94 neighbourx += 1;
95 newpos.Y = 1;
96 }
97 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
98
99 Hashtable SimParams;
100 ArrayList SendParams;
101 XmlRpcRequest GridReq;
102 XmlRpcResponse GridResp;
103 foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
104 {
105 if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
106 {
107 SimParams = new Hashtable();
108 SimParams["firstname"] = this.ClientAvatar.firstname;
109 SimParams["lastname"] = this.ClientAvatar.lastname;
110 SimParams["circuit_code"] = this.CircuitCode.ToString();
111 SimParams["pos_x"] = newpos.X.ToString();
112 SimParams["pos_y"] = newpos.Y.ToString();
113 SimParams["pos_z"] = newpos.Z.ToString();
114 SendParams = new ArrayList();
115 SendParams.Add(SimParams);
116
117 GridReq = new XmlRpcRequest("agent_crossing", SendParams);
118 GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
119
120 CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
121 NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
122 NewSimPack.AgentData.AgentID = this.AgentID;
123 NewSimPack.AgentData.SessionID = this.SessionID;
124 NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
125 NewSimPack.Info.Position = newpos;
126 NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
127 NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
128 NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
129 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
130 byte[] byteIP = neighbourIP.GetAddressBytes();
131 NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
132 NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
133 NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
134 NewSimPack.RegionData.SimIP += (uint)byteIP[0];
135 NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
136 NewSimPack.RegionData.SeedCapability = new byte[0];
137 lock (PacketQueue)
138 {
139 ProcessOutPacket(NewSimPack);
140 DowngradeClient();
141 }
142 }
143 }
144 }
145 }
146}