aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
diff options
context:
space:
mode:
authorMW2007-06-12 14:57:46 +0000
committerMW2007-06-12 14:57:46 +0000
commit4d217ca1969f8b1b92916cdb458d6febe16bef65 (patch)
tree37df37e01aa2585e6654ab7151c617999caa6c34 /OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
parentMore rearranging. (diff)
downloadopensim-SC-4d217ca1969f8b1b92916cdb458d6febe16bef65.zip
opensim-SC-4d217ca1969f8b1b92916cdb458d6febe16bef65.tar.gz
opensim-SC-4d217ca1969f8b1b92916cdb458d6febe16bef65.tar.bz2
opensim-SC-4d217ca1969f8b1b92916cdb458d6febe16bef65.tar.xz
And some more!
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs537
1 files changed, 0 insertions, 537 deletions
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
deleted file mode 100644
index b86d9e8..0000000
--- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs
+++ /dev/null
@@ -1,537 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using libsecondlife.Packets;
33using Nwc.XmlRpc;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Types;
41using OpenSim.Framework.Inventory;
42using OpenSim.Framework.Utilities;
43using OpenSim.Assets;
44
45namespace OpenSim
46{
47 public partial class ClientView
48 {
49 protected override void ProcessInPacket(Packet Pack)
50 {
51 ack_pack(Pack);
52 if (debug)
53 {
54 if (Pack.Type != PacketType.AgentUpdate)
55 {
56 Console.WriteLine(Pack.Type.ToString());
57 }
58 }
59
60 if (this.ProcessPacketMethod(Pack))
61 {
62 //there is a handler registered that handled this packet type
63 return;
64 }
65 else
66 {
67 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
68
69 switch (Pack.Type)
70 {
71 case PacketType.ViewerEffect:
72 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
73 foreach (ClientView client in m_clientThreads.Values)
74 {
75 if (client.AgentID != this.AgentID)
76 {
77 viewer.AgentData.AgentID = client.AgentID;
78 viewer.AgentData.SessionID = client.SessionID;
79 client.OutPacket(viewer);
80 }
81 }
82 break;
83
84 #region New Event System - World/Avatar
85 case PacketType.ChatFromViewer:
86 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
87 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
88 {
89 //empty message so don't bother with it
90 break;
91 }
92 string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
93 byte[] message = inchatpack.ChatData.Message;
94 byte type = inchatpack.ChatData.Type;
95 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos;
96 LLUUID fromAgentID = AgentID;
97 if (OnChatFromViewer != null)
98 {
99 this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
100 }
101 break;
102 case PacketType.RezObject:
103 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
104 AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
105 if (inven != null)
106 {
107 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
108 {
109 AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
110 if (asset != null)
111 {
112 if (OnRezObject != null)
113 {
114 this.OnRezObject(asset, rezPacket.RezData.RayEnd);
115 this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID);
116 }
117 }
118 }
119 }
120 break;
121 case PacketType.DeRezObject:
122 if (OnDeRezObject != null)
123 {
124 OnDeRezObject(Pack, this);
125 }
126 break;
127 case PacketType.ModifyLand:
128 ModifyLandPacket modify = (ModifyLandPacket)Pack;
129 if (modify.ParcelData.Length > 0)
130 {
131 if (OnModifyTerrain != null)
132 {
133 OnModifyTerrain(modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West);
134 }
135 }
136 break;
137 case PacketType.RegionHandshakeReply:
138 if (OnRegionHandShakeReply != null)
139 {
140 OnRegionHandShakeReply(this);
141 }
142 break;
143 case PacketType.AgentWearablesRequest:
144 if (OnRequestWearables != null)
145 {
146 OnRequestWearables(this);
147 }
148 if (OnRequestAvatarsData != null)
149 {
150 OnRequestAvatarsData(this);
151 }
152 break;
153 case PacketType.AgentSetAppearance:
154 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
155 if (OnSetAppearance != null)
156 {
157 OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
158 }
159 break;
160 case PacketType.CompleteAgentMovement:
161 if (this.m_child) this.UpgradeClient();
162 if (OnCompleteMovementToRegion != null)
163 {
164 OnCompleteMovementToRegion();
165 }
166 this.EnableNeighbours();
167 break;
168 case PacketType.AgentUpdate:
169 if (OnAgentUpdate != null)
170 {
171 OnAgentUpdate(Pack);
172 }
173 break;
174 case PacketType.AgentAnimation:
175 if (!m_child)
176 {
177 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
178 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
179 {
180 if (AgentAni.AnimationList[i].StartAnim)
181 {
182 if (OnStartAnim != null)
183 {
184 OnStartAnim(AgentAni.AnimationList[i].AnimID, 1);
185 }
186 }
187 }
188 }
189 break;
190
191 #endregion
192
193 #region New Event System - Objects/Prims
194 case PacketType.ObjectLink:
195 // OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
196 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
197 uint parentprimid = 0;
198 List<uint> childrenprims = new List<uint>();
199 if (link.ObjectData.Length > 1)
200 {
201 parentprimid = link.ObjectData[0].ObjectLocalID;
202
203 for (int i = 1; i < link.ObjectData.Length; i++)
204 {
205 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
206 }
207 }
208 if (OnLinkObjects != null)
209 {
210 OnLinkObjects(parentprimid, childrenprims);
211 }
212 break;
213 case PacketType.ObjectAdd:
214 // m_world.AddNewPrim((ObjectAddPacket)Pack, this);
215 if (OnAddPrim != null)
216 {
217 OnAddPrim(Pack, this);
218 }
219 break;
220 case PacketType.ObjectShape:
221 ObjectShapePacket shape = (ObjectShapePacket)Pack;
222 for (int i = 0; i < shape.ObjectData.Length; i++)
223 {
224 if (OnUpdatePrimShape != null)
225 {
226 OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]);
227 }
228 }
229 break;
230 case PacketType.ObjectSelect:
231 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
232 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
233 {
234 if (OnObjectSelect != null)
235 {
236 OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
237 }
238 }
239 break;
240 case PacketType.ObjectFlagUpdate:
241 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
242 if (OnUpdatePrimFlags != null)
243 {
244 OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
245 }
246 break;
247 case PacketType.ObjectImage:
248 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
249 for (int i = 0; i < imagePack.ObjectData.Length; i++)
250 {
251 if (OnUpdatePrimTexture != null)
252 {
253 OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this);
254 }
255 }
256 break;
257 #endregion
258
259 #region Inventory/Asset/Other related packets
260 case PacketType.RequestImage:
261 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
262 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
263 {
264 m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
265 }
266 break;
267 case PacketType.TransferRequest:
268 //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
269 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
270 m_assetCache.AddAssetRequest(this, transfer);
271 break;
272 case PacketType.AssetUploadRequest:
273 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
274 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
275 break;
276 case PacketType.RequestXfer:
277 //Console.WriteLine(Pack.ToString());
278 break;
279 case PacketType.SendXferPacket:
280 this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
281 break;
282 case PacketType.CreateInventoryFolder:
283 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
284 m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
285 //Console.WriteLine(Pack.ToString());
286 break;
287 case PacketType.CreateInventoryItem:
288 //Console.WriteLine(Pack.ToString());
289 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
290 if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
291 {
292 this.UploadAssets.CreateInventoryItem(createItem);
293 }
294 else
295 {
296 // Console.Write(Pack.ToString());
297 this.CreateInventoryItem(createItem);
298 }
299 break;
300 case PacketType.FetchInventory:
301 //Console.WriteLine("fetch item packet");
302 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
303 m_inventoryCache.FetchInventory(this, FetchInventory);
304 break;
305 case PacketType.FetchInventoryDescendents:
306 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
307 m_inventoryCache.FetchInventoryDescendents(this, Fetch);
308 break;
309 case PacketType.UpdateInventoryItem:
310 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
311 //Console.WriteLine(Pack.ToString());
312 for (int i = 0; i < update.InventoryData.Length; i++)
313 {
314 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
315 {
316 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
317 if (asset != null)
318 {
319 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
320 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
321 }
322 else
323 {
324 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
325 if (asset != null)
326 {
327 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
328 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
329 }
330 else
331 {
332 //Console.WriteLine("trying to update inventory item, but asset is null");
333 }
334 }
335 }
336 else
337 {
338 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
339 }
340 }
341 break;
342 case PacketType.RequestTaskInventory:
343 // Console.WriteLine(Pack.ToString());
344 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
345 ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
346 bool foundent = false;
347 /* foreach (Entity ent in m_world.Entities.Values)
348 {
349 if (ent.localid == requesttask.InventoryData.LocalID)
350 {
351 replytask.InventoryData.TaskID = ent.uuid;
352 replytask.InventoryData.Serial = 0;
353 replytask.InventoryData.Filename = new byte[0];
354 foundent = true;
355 }
356 }
357 if (foundent)
358 {
359 this.OutPacket(replytask);
360 }*/
361 break;
362 case PacketType.UpdateTaskInventory:
363 // Console.WriteLine(Pack.ToString());
364 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
365 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
366 /*if (myinventory != null)
367 {
368 if (updatetask.UpdateData.Key == 0)
369 {
370 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
371 {
372 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
373 {
374 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
375 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
376 if (assBase != null)
377 {
378 foreach (Entity ent in m_world.Entities.Values)
379 {
380 if (ent.localid == updatetask.UpdateData.LocalID)
381 {
382 if (ent is OpenSim.world.Primitive)
383 {
384 this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
385 }
386 }
387 }
388 }
389 }
390 }
391 }
392 }*/
393 break;
394 case PacketType.MapLayerRequest:
395 this.RequestMapLayer();
396 break;
397 case PacketType.MapBlockRequest:
398 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
399
400 this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
401 break;
402 case PacketType.TeleportLandmarkRequest:
403 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
404
405 TeleportStartPacket tpStart = new TeleportStartPacket();
406 tpStart.Info.TeleportFlags = 8; // tp via lm
407 this.OutPacket(tpStart);
408
409 TeleportProgressPacket tpProgress = new TeleportProgressPacket();
410 tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark");
411 tpProgress.Info.TeleportFlags = 8;
412 tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
413 this.OutPacket(tpProgress);
414
415 // Fetch landmark
416 LLUUID lmid = tpReq.Info.LandmarkID;
417 AssetBase lma = this.m_assetCache.GetAsset(lmid);
418 if (lma != null)
419 {
420 AssetLandmark lm = new AssetLandmark(lma);
421
422 if (lm.RegionID == m_regionData.SimUUID)
423 {
424 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
425
426 tpLocal.Info.AgentID = tpReq.Info.AgentID;
427 tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
428 tpLocal.Info.LocationID = 2;
429 tpLocal.Info.Position = lm.Position;
430 OutPacket(tpLocal);
431 }
432 else
433 {
434 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
435 tpCancel.Info.AgentID = tpReq.Info.AgentID;
436 tpCancel.Info.SessionID = tpReq.Info.SessionID;
437 OutPacket(tpCancel);
438 }
439 }
440 else
441 {
442 Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
443
444 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
445 tpCancel.Info.AgentID = tpReq.Info.AgentID;
446 tpCancel.Info.SessionID = tpReq.Info.SessionID;
447 OutPacket(tpCancel);
448 }
449 break;
450 case PacketType.TeleportLocationRequest:
451 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
452 Console.WriteLine(tpLocReq.ToString());
453
454 tpStart = new TeleportStartPacket();
455 tpStart.Info.TeleportFlags = 16; // Teleport via location
456 Console.WriteLine(tpStart.ToString());
457 OutPacket(tpStart);
458
459 if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle)
460 {
461 /* m_gridServer.getRegion(tpLocReq.Info.RegionHandle); */
462 Console.WriteLine("Inter-sim teleport not yet implemented");
463 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
464 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
465 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
466
467 OutPacket(tpCancel);
468 }
469 else
470 {
471 Console.WriteLine("Local teleport");
472 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
473 tpLocal.Info.AgentID = tpLocReq.AgentData.AgentID;
474 tpLocal.Info.TeleportFlags = tpStart.Info.TeleportFlags;
475 tpLocal.Info.LocationID = 2;
476 tpLocal.Info.LookAt = tpLocReq.Info.LookAt;
477 tpLocal.Info.Position = tpLocReq.Info.Position;
478 OutPacket(tpLocal);
479
480 }
481 break;
482 #endregion
483
484 #region Parcel related packets
485 case PacketType.ParcelPropertiesRequest:
486 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
487 if(OnParcelPropertiesRequest != null)
488 {
489 OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this);
490 }
491 break;
492 case PacketType.ParcelDivide:
493 ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack;
494 if (OnParcelDivideRequest != null)
495 {
496 OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this);
497 }
498 break;
499 case PacketType.ParcelJoin:
500 ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack;
501 if (OnParcelJoinRequest != null)
502 {
503 OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this);
504 }
505 break;
506 case PacketType.ParcelPropertiesUpdate:
507 ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack;
508 if (OnParcelPropertiesUpdateRequest != null)
509 {
510 OnParcelPropertiesUpdateRequest(updatePacket, this);
511 }
512 break;
513 #endregion
514
515 #region Estate Packets
516 case PacketType.EstateOwnerMessage:
517 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
518 if (OnEstateOwnerMessage != null)
519 {
520 OnEstateOwnerMessage(messagePacket, this);
521 }
522 break;
523 #endregion
524 #region unimplemented handlers
525 case PacketType.AgentIsNowWearing:
526 // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
527 //Console.WriteLine(Pack.ToString());
528 break;
529 case PacketType.ObjectScale:
530 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString());
531 break;
532 #endregion
533 }
534 }
535 }
536 }
537}