diff options
author | MW | 2007-04-17 12:03:52 +0000 |
---|---|---|
committer | MW | 2007-04-17 12:03:52 +0000 |
commit | d5406fe77309770234524f6afa38ae1502f01eab (patch) | |
tree | 1eacbc4c4f803087b7a2df77c43e8de65d91dbf2 /OpenSim.RegionServer/SimClient.cs | |
parent | Created skeleton SimComms.cs for sim<->sim UDP circuits (diff) | |
download | opensim-SC-d5406fe77309770234524f6afa38ae1502f01eab.zip opensim-SC-d5406fe77309770234524f6afa38ae1502f01eab.tar.gz opensim-SC-d5406fe77309770234524f6afa38ae1502f01eab.tar.bz2 opensim-SC-d5406fe77309770234524f6afa38ae1502f01eab.tar.xz |
A few fixes and stopped sim crossing being attempted in sandbox mode
Diffstat (limited to 'OpenSim.RegionServer/SimClient.cs')
-rw-r--r-- | OpenSim.RegionServer/SimClient.cs | 293 |
1 files changed, 156 insertions, 137 deletions
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index 52074b5..b729c6c 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs | |||
@@ -29,7 +29,7 @@ using System.Collections; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using Nwc.XmlRpc; | 32 | using Nwc.XmlRpc; |
33 | using System.Net; | 33 | using System.Net; |
34 | using System.Net.Sockets; | 34 | using System.Net.Sockets; |
35 | using System.IO; | 35 | using System.IO; |
@@ -55,13 +55,13 @@ namespace OpenSim | |||
55 | public LLUUID AgentID; | 55 | public LLUUID AgentID; |
56 | public LLUUID SessionID; | 56 | public LLUUID SessionID; |
57 | public LLUUID SecureSessionID = LLUUID.Zero; | 57 | public LLUUID SecureSessionID = LLUUID.Zero; |
58 | public bool m_child; | 58 | public bool m_child; |
59 | public uint CircuitCode; | 59 | public uint CircuitCode; |
60 | public world.Avatar ClientAvatar; | 60 | public world.Avatar ClientAvatar; |
61 | private UseCircuitCodePacket cirpack; | 61 | private UseCircuitCodePacket cirpack; |
62 | public Thread ClientThread; | 62 | public Thread ClientThread; |
63 | public EndPoint userEP; | 63 | public EndPoint userEP; |
64 | public LLVector3 startpos; | 64 | public LLVector3 startpos; |
65 | private BlockingQueue<QueItem> PacketQueue; | 65 | private BlockingQueue<QueItem> PacketQueue; |
66 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | 66 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); |
67 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | 67 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); |
@@ -82,8 +82,9 @@ namespace OpenSim | |||
82 | private IUserServer m_userServer = null; | 82 | private IUserServer m_userServer = null; |
83 | private OpenSimNetworkHandler m_application; | 83 | private OpenSimNetworkHandler m_application; |
84 | private InventoryCache m_inventoryCache; | 84 | private InventoryCache m_inventoryCache; |
85 | private bool m_sandboxMode; | 85 | public bool m_sandboxMode; |
86 | private int cachedtextureserial = 0; | 86 | private int cachedtextureserial = 0; |
87 | private RegionInfo m_regionData; | ||
87 | 88 | ||
88 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | 89 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients |
89 | 90 | ||
@@ -97,7 +98,7 @@ namespace OpenSim | |||
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child) | 101 | public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat) |
101 | { | 102 | { |
102 | m_world = world; | 103 | m_world = world; |
103 | m_clientThreads = clientThreads; | 104 | m_clientThreads = clientThreads; |
@@ -106,16 +107,20 @@ namespace OpenSim | |||
106 | m_application = application; | 107 | m_application = application; |
107 | m_inventoryCache = inventoryCache; | 108 | m_inventoryCache = inventoryCache; |
108 | m_sandboxMode = sandboxMode; | 109 | m_sandboxMode = sandboxMode; |
109 | m_child=child; | 110 | m_child = child; |
111 | m_regionData = regionDat; | ||
110 | 112 | ||
111 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); | 113 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); |
112 | cirpack = initialcirpack; | 114 | cirpack = initialcirpack; |
113 | userEP = remoteEP; | 115 | userEP = remoteEP; |
114 | if(m_gridServer.GetName() == "Remote") { | 116 | if (m_gridServer.GetName() == "Remote") |
115 | this.startpos=((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos; | 117 | { |
116 | } else { | 118 | this.startpos = ((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos; |
117 | this.startpos=new LLVector3(128.0f,128.0f,60f); | 119 | } |
118 | } | 120 | else |
121 | { | ||
122 | this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 1.0f); // new LLVector3(128.0f, 128.0f, 60f); | ||
123 | } | ||
119 | PacketQueue = new BlockingQueue<QueItem>(); | 124 | PacketQueue = new BlockingQueue<QueItem>(); |
120 | 125 | ||
121 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); | 126 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); |
@@ -137,115 +142,128 @@ namespace OpenSim | |||
137 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); | 142 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); |
138 | } | 143 | } |
139 | 144 | ||
140 | public void CrossSimBorder(LLVector3 avatarpos) { // VERY VERY BASIC | 145 | public void CrossSimBorder(LLVector3 avatarpos) |
141 | LLVector3 newpos = avatarpos; | 146 | { // VERY VERY BASIC |
142 | uint neighbourx=((OpenSimMain)m_application).regionData.RegionLocX; | 147 | LLVector3 newpos = this.m_regionData.RegionLocX; |
143 | uint neighboury=((OpenSimMain)m_application).regionData.RegionLocY; | 148 | uint neighboury = this.m_regionData.RegionLocY; |
144 | 149 | ||
145 | if(avatarpos.X<0) { | 150 | if (avatarpos.X < 0) |
146 | neighbourx-=1; | 151 | { |
147 | newpos.X=254; | 152 | neighbourx -= 1; |
148 | } | 153 | newpos.X = 254; |
149 | if(avatarpos.X>255) { | 154 | } |
150 | neighbourx+=1; | 155 | if (avatarpos.X > 255) |
151 | newpos.X=1; | 156 | { |
152 | } | 157 | neighbourx += 1; |
153 | if(avatarpos.Y<0) { | 158 | newpos.X = 1; |
154 | neighboury-=1; | 159 | } |
155 | newpos.Y=254; | 160 | if (avatarpos.Y < 0) |
156 | } | 161 | { |
157 | if(avatarpos.Y>255) { | 162 | neighboury -= 1; |
158 | neighbourx+=1; | 163 | newpos.Y = 254; |
159 | newpos.Y=1; | 164 | } |
160 | } | 165 | if (avatarpos.Y > 255) |
161 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]"); | 166 | { |
162 | 167 | neighbourx += 1; | |
163 | Hashtable SimParams; | 168 | newpos.Y = 1; |
164 | ArrayList SendParams; | 169 | } |
165 | XmlRpcRequest GridReq; | 170 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]"); |
166 | XmlRpcResponse GridResp; | 171 | |
167 | foreach(Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours) { | 172 | Hashtable SimParams; |
168 | if(((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString())) { | 173 | ArrayList SendParams; |
169 | SimParams = new Hashtable(); | 174 | XmlRpcRequest GridReq; |
170 | SimParams["firstname"] = this.ClientAvatar.firstname; | 175 | XmlRpcResponse GridResp; |
171 | SimParams["lastname"] = this.ClientAvatar.lastname; | 176 | foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours) |
172 | SimParams["circuit_code"] = this.CircuitCode.ToString(); | 177 | { |
173 | SimParams["pos_x"] = newpos.X.ToString(); | 178 | if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString())) |
174 | SimParams["pos_y"] = newpos.Y.ToString(); | 179 | { |
175 | SimParams["pos_z"] = newpos.Z.ToString(); | 180 | SimParams = new Hashtable(); |
176 | SendParams = new ArrayList(); | 181 | SimParams["firstname"] = this.ClientAvatar.firstname; |
177 | SendParams.Add(SimParams); | 182 | SimParams["lastname"] = this.ClientAvatar.lastname; |
178 | 183 | SimParams["circuit_code"] = this.CircuitCode.ToString(); | |
179 | GridReq = new XmlRpcRequest("agent_crossing", SendParams); | 184 | SimParams["pos_x"] = newpos.X.ToString(); |
180 | GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000); | 185 | SimParams["pos_y"] = newpos.Y.ToString(); |
181 | 186 | SimParams["pos_z"] = newpos.Z.ToString(); | |
182 | CrossedRegionPacket NewSimPack = new CrossedRegionPacket(); | 187 | SendParams = new ArrayList(); |
183 | NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); | 188 | SendParams.Add(SimParams); |
184 | NewSimPack.AgentData.AgentID=this.AgentID; | 189 | |
185 | NewSimPack.AgentData.SessionID=this.SessionID; | 190 | GridReq = new XmlRpcRequest("agent_crossing", SendParams); |
186 | NewSimPack.Info = new CrossedRegionPacket.InfoBlock(); | 191 | GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000); |
187 | NewSimPack.Info.Position=newpos; | 192 | |
188 | NewSimPack.Info.LookAt=new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! | 193 | CrossedRegionPacket NewSimPack = new CrossedRegionPacket(); |
189 | NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); | 194 | NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); |
190 | NewSimPack.RegionData.RegionHandle=Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256)); | 195 | NewSimPack.AgentData.AgentID = this.AgentID; |
191 | 196 | NewSimPack.AgentData.SessionID = this.SessionID; | |
192 | System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]); | 197 | NewSimPack.Info = new CrossedRegionPacket.InfoBlock(); |
193 | byte[] byteIP = neighbourIP.GetAddressBytes(); | 198 | NewSimPack.Info.Position = newpos; |
194 | NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; | 199 | NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! |
195 | NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; | 200 | NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); |
196 | NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; | 201 | NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256)); |
197 | NewSimPack.RegionData.SimIP += (uint)byteIP[0]; | 202 | |
198 | NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]); | 203 | System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]); |
199 | NewSimPack.RegionData.SeedCapability = new byte[0]; | 204 | byte[] byteIP = neighbourIP.GetAddressBytes(); |
200 | lock(PacketQueue) { | 205 | NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; |
201 | ProcessOutPacket(NewSimPack); | 206 | NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; |
202 | DowngradeClient(); | 207 | NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; |
203 | } | 208 | NewSimPack.RegionData.SimIP += (uint)byteIP[0]; |
204 | } | 209 | NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]); |
205 | } | 210 | NewSimPack.RegionData.SeedCapability = new byte[0]; |
206 | } | 211 | lock (PacketQueue) |
207 | 212 | { | |
208 | public void UpgradeClient() { | 213 | ProcessOutPacket(NewSimPack); |
209 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - upgrading child to full agent"); | 214 | DowngradeClient(); |
210 | this.m_child=false; | 215 | } |
211 | this.m_world.RemoveViewerAgent(this); | 216 | } |
212 | this.startpos=((RemoteGridBase)m_gridServer).agentcircuits[CircuitCode].startpos; | 217 | } |
213 | ((RemoteGridBase)m_gridServer).agentcircuits[CircuitCode].child=false; | 218 | } |
214 | this.InitNewClient(); | 219 | |
215 | } | 220 | public void UpgradeClient() |
216 | 221 | { | |
217 | public void DowngradeClient() { | 222 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - upgrading child to full agent"); |
218 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - changing full agent to child"); | 223 | this.m_child = false; |
219 | this.m_child=true; | 224 | this.m_world.RemoveViewerAgent(this); |
220 | this.m_world.RemoveViewerAgent(this); | 225 | if (!this.m_sandboxMode) |
221 | this.m_world.AddViewerAgent(this); | 226 | { |
222 | } | 227 | this.startpos = ((RemoteGridBase)m_gridServer).agentcircuits[CircuitCode].startpos; |
223 | 228 | ((RemoteGridBase)m_gridServer).agentcircuits[CircuitCode].child = false; | |
224 | public void KillClient() { | 229 | } |
225 | KillObjectPacket kill = new KillObjectPacket(); | 230 | this.InitNewClient(); |
226 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 231 | } |
227 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 232 | |
228 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | 233 | public void DowngradeClient() |
229 | foreach (SimClient client in m_clientThreads.Values) | 234 | { |
230 | { | 235 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - changing full agent to child"); |
231 | client.OutPacket(kill); | 236 | this.m_child = true; |
232 | } | 237 | this.m_world.RemoveViewerAgent(this); |
233 | if (this.m_userServer != null) | 238 | this.m_world.AddViewerAgent(this); |
234 | { | 239 | } |
235 | this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); | 240 | |
236 | } | 241 | public void KillClient() |
237 | else | 242 | { |
238 | { | 243 | KillObjectPacket kill = new KillObjectPacket(); |
239 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | 244 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
240 | } | 245 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
241 | 246 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | |
242 | m_world.RemoveViewerAgent(this); | 247 | foreach (SimClient client in m_clientThreads.Values) |
243 | 248 | { | |
244 | m_clientThreads.Remove(this.CircuitCode); | 249 | client.OutPacket(kill); |
245 | m_application.RemoveClientCircuit(this.CircuitCode); | 250 | } |
246 | this.ClientThread.Abort(); | 251 | if (this.m_userServer != null) |
247 | } | 252 | { |
248 | 253 | this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); | |
254 | } | ||
255 | else | ||
256 | { | ||
257 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | ||
258 | } | ||
259 | |||
260 | m_world.RemoveViewerAgent(this); | ||
261 | |||
262 | m_clientThreads.Remove(this.CircuitCode); | ||
263 | m_application.RemoveClientCircuit(this.CircuitCode); | ||
264 | this.ClientThread.Abort(); | ||
265 | } | ||
266 | |||
249 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) | 267 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) |
250 | { | 268 | { |
251 | bool result = false; | 269 | bool result = false; |
@@ -346,9 +364,9 @@ namespace OpenSim | |||
346 | switch (Pack.Type) | 364 | switch (Pack.Type) |
347 | { | 365 | { |
348 | case PacketType.CompleteAgentMovement: | 366 | case PacketType.CompleteAgentMovement: |
349 | if(this.m_child) this.UpgradeClient(); | 367 | if (this.m_child) this.UpgradeClient(); |
350 | ClientAvatar.CompleteMovement(m_world); | 368 | ClientAvatar.CompleteMovement(m_world); |
351 | ClientAvatar.SendInitialPosition(); | 369 | ClientAvatar.SendInitialPosition(); |
352 | break; | 370 | break; |
353 | case PacketType.RegionHandshakeReply: | 371 | case PacketType.RegionHandshakeReply: |
354 | m_world.SendLayerData(this); | 372 | m_world.SendLayerData(this); |
@@ -595,18 +613,19 @@ namespace OpenSim | |||
595 | } | 613 | } |
596 | break; | 614 | break; |
597 | case PacketType.AgentAnimation: | 615 | case PacketType.AgentAnimation: |
598 | if(!m_child) { | 616 | if (!m_child) |
599 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | 617 | { |
600 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | 618 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; |
601 | { | 619 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) |
602 | if (AgentAni.AnimationList[i].StartAnim) | 620 | { |
603 | { | 621 | if (AgentAni.AnimationList[i].StartAnim) |
604 | ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; | 622 | { |
605 | ClientAvatar.anim_seq = 1; | 623 | ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; |
606 | ClientAvatar.SendAnimPack(); | 624 | ClientAvatar.anim_seq = 1; |
607 | } | 625 | ClientAvatar.SendAnimPack(); |
608 | } | 626 | } |
609 | } | 627 | } |
628 | } | ||
610 | break; | 629 | break; |
611 | case PacketType.ObjectSelect: | 630 | case PacketType.ObjectSelect: |
612 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | 631 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; |
@@ -912,7 +931,7 @@ namespace OpenSim | |||
912 | } | 931 | } |
913 | } | 932 | } |
914 | #region Packet handlers | 933 | #region Packet handlers |
915 | 934 | ||
916 | protected virtual bool Logout(SimClient simClient, Packet packet) | 935 | protected virtual bool Logout(SimClient simClient, Packet packet) |
917 | { | 936 | { |
918 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | 937 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); |