aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/SimClient.PacketHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/SimClient.PacketHandlers.cs')
-rw-r--r--OpenSim.RegionServer/SimClient.PacketHandlers.cs156
1 files changed, 156 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/SimClient.PacketHandlers.cs b/OpenSim.RegionServer/SimClient.PacketHandlers.cs
new file mode 100644
index 0000000..5007a60
--- /dev/null
+++ b/OpenSim.RegionServer/SimClient.PacketHandlers.cs
@@ -0,0 +1,156 @@
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 protected virtual bool Logout(SimClient simClient, Packet packet)
24 {
25 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
26 //send reply to let the client logout
27 LogoutReplyPacket logReply = new LogoutReplyPacket();
28 logReply.AgentData.AgentID = this.AgentID;
29 logReply.AgentData.SessionID = this.SessionID;
30 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
31 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
32 logReply.InventoryData[0].ItemID = LLUUID.Zero;
33 OutPacket(logReply);
34 //tell all clients to kill our object
35 KillObjectPacket kill = new KillObjectPacket();
36 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
37 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
38 kill.ObjectData[0].ID = this.ClientAvatar.localid;
39 foreach (SimClient client in m_clientThreads.Values)
40 {
41 client.OutPacket(kill);
42 }
43 if (this.m_userServer != null)
44 {
45 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
46 }
47 else
48 {
49 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
50 }
51
52 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
53 /*lock (m_world.Entities)
54 {
55 m_world.Entities.Remove(this.AgentID);
56 }*/
57 m_world.RemoveViewerAgent(this);
58 //need to do other cleaning up here too
59 m_clientThreads.Remove(this.CircuitCode);
60 m_application.RemoveClientCircuit(this.CircuitCode);
61 this.ClientThread.Abort();
62 return true;
63 }
64
65 protected bool AgentTextureCached(SimClient simclient, Packet packet)
66 {
67 // Console.WriteLine(packet.ToString());
68 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
69 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
70 cachedresp.AgentData.AgentID = this.AgentID;
71 cachedresp.AgentData.SessionID = this.SessionID;
72 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
73 this.cachedtextureserial++;
74 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
75 for (int i = 0; i < chechedtex.WearableData.Length; i++)
76 {
77 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
78 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
79 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
80 cachedresp.WearableData[i].HostName = new byte[0];
81 }
82 this.OutPacket(cachedresp);
83 return true;
84 }
85
86 protected bool MultipleObjUpdate(SimClient simClient, Packet packet)
87 {
88 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
89 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
90 {
91 if (multipleupdate.ObjectData[i].Type == 9) //change position
92 {
93 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
94 foreach (Entity ent in m_world.Entities.Values)
95 {
96 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
97 {
98 ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
99
100 }
101 }
102 //should update stored position of the prim
103 }
104 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
105 {
106 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
107 foreach (Entity ent in m_world.Entities.Values)
108 {
109 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
110 {
111 ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
112 ((OpenSim.world.Primitive)ent).UpdateFlag = true;
113 }
114 }
115 }
116 else if (multipleupdate.ObjectData[i].Type == 13)//scale
117 {
118
119 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
120 foreach (Entity ent in m_world.Entities.Values)
121 {
122 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
123 {
124 ((OpenSim.world.Primitive)ent).Scale = scale;
125 }
126 }
127 }
128 }
129 return true;
130 }
131
132 public void RequestMapLayer() //should be getting the map layer from the grid server
133 {
134 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
135 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
136 mapReply.AgentData.AgentID = this.AgentID;
137 mapReply.AgentData.Flags = 0;
138 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
139 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
140 mapReply.LayerData[0].Bottom = 800;
141 mapReply.LayerData[0].Left = 800;
142 mapReply.LayerData[0].Top = 1200;
143 mapReply.LayerData[0].Right = 1200;
144 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
145 this.OutPacket(mapReply);
146 }
147
148 public void RequestMapBlock(int minX, int minY, int maxX, int maxY)
149 {
150 //check if our own map was requested
151 this.m_world.RequestMapBlock(this, minX, minY, maxX, maxY);
152
153 //now should get other regions maps from gridserver
154 }
155 }
156}