aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/ClientView.ProcessPackets.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:16:50 +0000
committerMW2007-05-24 12:16:50 +0000
commit3376b82501000692d6dac24b051af738cdaf2737 (patch)
tree90ed0a5d4955236f011fa63fce9d555186b0d179 /OpenSim.RegionServer/ClientView.ProcessPackets.cs
parentAdded "terrain save grdmap <filename> <gradientmap>" function to console. Gra... (diff)
downloadopensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.zip
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.gz
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.bz2
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.xz
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'OpenSim.RegionServer/ClientView.ProcessPackets.cs')
-rw-r--r--OpenSim.RegionServer/ClientView.ProcessPackets.cs471
1 files changed, 0 insertions, 471 deletions
diff --git a/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim.RegionServer/ClientView.ProcessPackets.cs
deleted file mode 100644
index a78f27a..0000000
--- a/OpenSim.RegionServer/ClientView.ProcessPackets.cs
+++ /dev/null
@@ -1,471 +0,0 @@
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 ClientView
22 {
23 public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
24 public delegate void RezObject(AssetBase primasset, LLVector3 pos);
25 public delegate void ModifyTerrain(byte Action, float North, float West);
26 public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
27 public delegate void StartAnim(LLUUID animID, int seq);
28 public delegate void GenericCall(ClientView RemoteClient);
29 public delegate void GenericCall2();
30 public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary.
31
32 public event ChatFromViewer OnChatFromViewer;
33 public event RezObject OnRezObject;
34 public event ModifyTerrain OnModifyTerrain;
35 public event GenericCall OnRegionHandShakeReply;
36 public event GenericCall OnRequestWearables;
37 public event SetAppearance OnSetAppearance;
38 public event GenericCall2 OnCompleteMovementToRegion;
39 public event GenericCall3 OnAgentUpdate;
40 public event StartAnim OnStartAnim;
41 public event GenericCall OnRequestAvatarsData;
42
43 protected override void ProcessInPacket(Packet Pack)
44 {
45 ack_pack(Pack);
46 if (debug)
47 {
48 if (Pack.Type != PacketType.AgentUpdate)
49 {
50 Console.WriteLine(Pack.Type.ToString());
51 }
52 }
53
54 if (this.ProcessPacketMethod(Pack))
55 {
56 //there is a handler registered that handled this packet type
57 return;
58 }
59 else
60 {
61 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
62
63 switch (Pack.Type)
64 {
65 #region New Event system
66 case PacketType.ChatFromViewer:
67 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
68 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
69 {
70 //empty message so don't bother with it
71 break;
72 }
73 string fromName = ClientAvatar.firstname + " " + ClientAvatar.lastname;
74 byte[] message = inchatpack.ChatData.Message;
75 byte type = inchatpack.ChatData.Type;
76 LLVector3 fromPos = ClientAvatar.Pos;
77 LLUUID fromAgentID = AgentID;
78 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
79 break;
80 case PacketType.RezObject:
81 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
82 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
83 if (inven != null)
84 {
85 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
86 {
87 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
88 if (asset != null)
89 {
90 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
91 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
92 }
93 }
94 }
95 break;
96 case PacketType.ModifyLand:
97 ModifyLandPacket modify = (ModifyLandPacket)Pack;
98 if (modify.ParcelData.Length > 0)
99 {
100 OnModifyTerrain(modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
101 }
102 break;
103
104 case PacketType.RegionHandshakeReply:
105 OnRegionHandShakeReply(this);
106 break;
107 case PacketType.AgentWearablesRequest:
108 OnRequestWearables(this);
109 OnRequestAvatarsData(this);
110 break;
111 case PacketType.AgentSetAppearance:
112 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
113 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
114 break;
115 case PacketType.CompleteAgentMovement:
116 if (this.m_child) this.UpgradeClient();
117 OnCompleteMovementToRegion();
118 this.EnableNeighbours();
119 break;
120 case PacketType.AgentUpdate:
121 OnAgentUpdate(Pack);
122 break;
123 case PacketType.AgentAnimation:
124 if (!m_child)
125 {
126 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
127 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
128 {
129 if (AgentAni.AnimationList[i].StartAnim)
130 {
131 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
132 }
133 }
134 }
135 break;
136 case PacketType.AgentIsNowWearing:
137 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
138 //Console.WriteLine(Pack.ToString());
139 break;
140 #endregion
141
142 //old handling, should move most to a event based system.
143 #region World/Avatar/Primitive related packets
144 case PacketType.ObjectAdd:
145 m_world.AddNewPrim((ObjectAddPacket)Pack, this);
146 break;
147 case PacketType.ObjectLink:
148 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
149 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
150 uint parentprimid = 0;
151 OpenSim.world.Primitive parentprim = null;
152 if (link.ObjectData.Length > 1)
153 {
154 parentprimid = link.ObjectData[0].ObjectLocalID;
155 foreach (Entity ent in m_world.Entities.Values)
156 {
157 if (ent.localid == parentprimid)
158 {
159 parentprim = (OpenSim.world.Primitive)ent;
160
161 }
162 }
163 for (int i = 1; i < link.ObjectData.Length; i++)
164 {
165 foreach (Entity ent in m_world.Entities.Values)
166 {
167 if (ent.localid == link.ObjectData[i].ObjectLocalID)
168 {
169 ((OpenSim.world.Primitive)ent).MakeParent(parentprim);
170 }
171 }
172 }
173 }
174 break;
175 case PacketType.ObjectScale:
176 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
177 break;
178 case PacketType.ObjectShape:
179 ObjectShapePacket shape = (ObjectShapePacket)Pack;
180 for (int i = 0; i < shape.ObjectData.Length; i++)
181 {
182 foreach (Entity ent in m_world.Entities.Values)
183 {
184 if (ent.localid == shape.ObjectData[i].ObjectLocalID)
185 {
186 ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]);
187 }
188 }
189 }
190 break;
191 case PacketType.ObjectSelect:
192 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
193 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
194 {
195 foreach (Entity ent in m_world.Entities.Values)
196 {
197 if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID)
198 {
199 ((OpenSim.world.Primitive)ent).GetProperites(this);
200 break;
201 }
202 }
203 }
204 break;
205 case PacketType.ObjectImage:
206 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
207 for (int i = 0; i < imagePack.ObjectData.Length; i++)
208 {
209 foreach (Entity ent in m_world.Entities.Values)
210 {
211 if (ent.localid == imagePack.ObjectData[i].ObjectLocalID)
212 {
213 ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry);
214 }
215 }
216 }
217 break;
218 case PacketType.ObjectFlagUpdate:
219 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
220 foreach (Entity ent in m_world.Entities.Values)
221 {
222 if (ent.localid == flags.AgentData.ObjectLocalID)
223 {
224 ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags);
225 }
226 }
227 break;
228
229 case PacketType.ViewerEffect:
230 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
231 foreach (ClientView client in m_clientThreads.Values)
232 {
233 if (client.AgentID != this.AgentID)
234 {
235 viewer.AgentData.AgentID = client.AgentID;
236 viewer.AgentData.SessionID = client.SessionID;
237 client.OutPacket(viewer);
238 }
239 }
240 break;
241 #endregion
242
243 #region Inventory/Asset/Other related packets
244 case PacketType.RequestImage:
245 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
246 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
247 {
248 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
249 }
250 break;
251 case PacketType.TransferRequest:
252 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
253 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
254 m_assetCache.AddAssetRequest(this, transfer);
255 break;
256 case PacketType.AssetUploadRequest:
257 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
258 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
259 break;
260 case PacketType.RequestXfer:
261 //Console.WriteLine(Pack.ToString());
262 break;
263 case PacketType.SendXferPacket:
264 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
265 break;
266 case PacketType.CreateInventoryFolder:
267 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
268 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
269 //Console.WriteLine(Pack.ToString());
270 break;
271 case PacketType.CreateInventoryItem:
272 //Console.WriteLine(Pack.ToString());
273 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
274 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
275 {
276 this.UploadAssets.CreateInventoryItem(createItem);
277 }
278 else
279 {
280 // Console.Write(Pack.ToString());
281 this.CreateInventoryItem(createItem);
282 }
283 break;
284 case PacketType.FetchInventory:
285 //Console.WriteLine("fetch item packet");
286 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
287 m_inventoryCache.FetchInventory(this, FetchInventory);
288 break;
289 case PacketType.FetchInventoryDescendents:
290 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
291 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
292 break;
293 case PacketType.UpdateInventoryItem:
294 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
295 //Console.WriteLine(Pack.ToString());
296 for (int i = 0; i < update.InventoryData.Length; i++)
297 {
298 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
299 {
300 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
301 if (asset != null)
302 {
303 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
304 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
305 }
306 else
307 {
308 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
309 if (asset != null)
310 {
311 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
312 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
313 }
314 else
315 {
316 //Console.WriteLine("trying to update inventory item, but asset is null");
317 }
318 }
319 }
320 else
321 {
322 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
323 }
324 }
325 break;
326 case PacketType.RequestTaskInventory:
327 // Console.WriteLine(Pack.ToString());
328 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
329 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
330 bool foundent = false;
331 foreach (Entity ent in m_world.Entities.Values)
332 {
333 if (ent.localid == requesttask.InventoryData.LocalID)
334 {
335 replytask.InventoryData.TaskID = ent.uuid;
336 replytask.InventoryData.Serial = 0;
337 replytask.InventoryData.Filename = new byte[0];
338 foundent = true;
339 }
340 }
341 if (foundent)
342 {
343 this.OutPacket(replytask);
344 }
345 break;
346 case PacketType.UpdateTaskInventory:
347 // Console.WriteLine(Pack.ToString());
348 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
349 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
350 if (myinventory != null)
351 {
352 if (updatetask.UpdateData.Key == 0)
353 {
354 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
355 {
356 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
357 {
358 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
359 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
360 if (assBase != null)
361 {
362 foreach (Entity ent in m_world.Entities.Values)
363 {
364 if (ent.localid == updatetask.UpdateData.LocalID)
365 {
366 if (ent is OpenSim.world.Primitive)
367 {
368 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
369 }
370 }
371 }
372 }
373 }
374 }
375 }
376 }
377 break;
378 case PacketType.MapLayerRequest:
379 this.RequestMapLayer();
380 break;
381 case PacketType.MapBlockRequest:
382 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
383
384 this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
385 break;
386 case PacketType.TeleportLandmarkRequest:
387 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
388
389 TeleportStartPacket tpStart = new TeleportStartPacket();
390 tpStart.Info.TeleportFlags = 8; // tp via lm
391 this.OutPacket(tpStart);
392
393 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
394 tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark");
395 tpProgress.Info.TeleportFlags = 8;
396 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
397 this.OutPacket(tpProgress);
398
399 // Fetch landmark
400 LLUUID lmid = tpReq.Info.LandmarkID;
401 AssetBase lma = this.m_assetCache.GetAsset(lmid);
402 if (lma != null)
403 {
404 AssetLandmark lm = new AssetLandmark(lma);
405
406 if (lm.RegionID == m_regionData.SimUUID)
407 {
408 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
409
410 tpLocal.Info.AgentID = tpReq.Info.AgentID;
411 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
412 tpLocal.Info.LocationID = 2;
413 tpLocal.Info.Position = lm.Position;
414 OutPacket(tpLocal);
415 }
416 else
417 {
418 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
419 tpCancel.Info.AgentID = tpReq.Info.AgentID;
420 tpCancel.Info.SessionID = tpReq.Info.SessionID;
421 OutPacket(tpCancel);
422 }
423 }
424 else
425 {
426 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
427
428 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
429 tpCancel.Info.AgentID = tpReq.Info.AgentID;
430 tpCancel.Info.SessionID = tpReq.Info.SessionID;
431 OutPacket(tpCancel);
432 }
433 break;
434 case PacketType.TeleportLocationRequest:
435 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
436 Console.WriteLine(tpLocReq.ToString());
437
438 tpStart = new TeleportStartPacket();
439 tpStart.Info.TeleportFlags = 16; // Teleport via location
440 Console.WriteLine(tpStart.ToString());
441 OutPacket(tpStart);
442
443 if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle)
444 {
445 /* m_gridServer.getRegion(tpLocReq.Info.RegionHandle); */
446 Console.WriteLine("Inter-sim teleport not yet implemented");
447 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
448 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
449 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
450
451 OutPacket(tpCancel);
452 }
453 else
454 {
455 Console.WriteLine("Local teleport");
456 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
457 tpLocal.Info.AgentID = tpLocReq.AgentData.AgentID;
458 tpLocal.Info.TeleportFlags = tpStart.Info.TeleportFlags;
459 tpLocal.Info.LocationID = 2;
460 tpLocal.Info.LookAt = tpLocReq.Info.LookAt;
461 tpLocal.Info.Position = tpLocReq.Info.Position;
462 OutPacket(tpLocal);
463
464 }
465 break;
466 #endregion
467 }
468 }
469 }
470 }
471}