aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs222
1 files changed, 222 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..035eb4c
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs
@@ -0,0 +1,222 @@
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 virtual void RegisterLocalPacketHandlers()
50 {
51 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
52 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
53 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
54 }
55
56 protected virtual bool Logout(ClientView simClient, Packet packet)
57 {
58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
59 //send reply to let the client logout
60 LogoutReplyPacket logReply = new LogoutReplyPacket();
61 logReply.AgentData.AgentID = this.AgentID;
62 logReply.AgentData.SessionID = this.SessionID;
63 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
64 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
65 logReply.InventoryData[0].ItemID = LLUUID.Zero;
66 OutPacket(logReply);
67 //tell all clients to kill our object
68 KillObjectPacket kill = new KillObjectPacket();
69 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
70 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
71 // kill.ObjectData[0].ID = this.ClientAvatar.localid;
72 foreach (ClientView client in m_clientThreads.Values)
73 {
74 client.OutPacket(kill);
75 }
76
77 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
78
79
80 // m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
81 /*lock (m_world.Entities)
82 {
83 m_world.Entities.Remove(this.AgentID);
84 }*/
85 // m_world.RemoveViewerAgent(this);
86 //need to do other cleaning up here too
87 m_clientThreads.Remove(this.CircuitCode);
88 m_networkServer.RemoveClientCircuit(this.CircuitCode);
89 this.ClientThread.Abort();
90 return true;
91 }
92
93 protected bool AgentTextureCached(ClientView simclient, Packet packet)
94 {
95 // Console.WriteLine(packet.ToString());
96 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
97 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
98 cachedresp.AgentData.AgentID = this.AgentID;
99 cachedresp.AgentData.SessionID = this.SessionID;
100 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
101 this.cachedtextureserial++;
102 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
103 for (int i = 0; i < chechedtex.WearableData.Length; i++)
104 {
105 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
106 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
107 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
108 cachedresp.WearableData[i].HostName = new byte[0];
109 }
110 this.OutPacket(cachedresp);
111 return true;
112 }
113
114 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
115 {
116 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
117 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
118 {
119 if (multipleupdate.ObjectData[i].Type == 9) //change position
120 {
121 if (OnUpdatePrimPosition != null)
122 {
123 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
124 OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
125 }
126 //should update stored position of the prim
127 }
128 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
129 {
130 if (OnUpdatePrimRotation != null)
131 {
132 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
133 OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
134 }
135 }
136 else if (multipleupdate.ObjectData[i].Type == 13)//scale
137 {
138 if (OnUpdatePrimScale != null)
139 {
140 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
141 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
142 }
143 }
144 }
145 return true;
146 }
147
148 public void RequestMapLayer() //should be getting the map layer from the grid server
149 {
150 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
151 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
152 mapReply.AgentData.AgentID = this.AgentID;
153 mapReply.AgentData.Flags = 0;
154 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
155 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
156 mapReply.LayerData[0].Bottom = 800;
157 mapReply.LayerData[0].Left = 800;
158 mapReply.LayerData[0].Top = 1200;
159 mapReply.LayerData[0].Right = 1200;
160 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
161 this.OutPacket(mapReply);
162 }
163
164 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
165 {
166 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
167 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
168 mbReply.AgentData.AgentID = this.AgentID;
169 int len;
170 if (simMapProfiles == null)
171 len = 0;
172 else
173 len = simMapProfiles.Count;
174
175 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
176 int iii;
177 for (iii = 0; iii < len; iii++)
178 {
179 Hashtable mp = (Hashtable)simMapProfiles[iii];
180 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
181 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
182 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
183 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
184 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
185 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
186 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
187 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
188 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
189 }
190 this.OutPacket(mbReply);
191 }
192
193 protected PrimData CreatePrimFromObjectAdd(ObjectAddPacket addPacket)
194 {
195 PrimData PData = new PrimData();
196 PData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
197 PData.PCode = addPacket.ObjectData.PCode;
198 PData.PathBegin = addPacket.ObjectData.PathBegin;
199 PData.PathEnd = addPacket.ObjectData.PathEnd;
200 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
201 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
202 PData.PathShearX = addPacket.ObjectData.PathShearX;
203 PData.PathShearY = addPacket.ObjectData.PathShearY;
204 PData.PathSkew = addPacket.ObjectData.PathSkew;
205 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
206 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
207 PData.Scale = addPacket.ObjectData.Scale;
208 PData.PathCurve = addPacket.ObjectData.PathCurve;
209 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
210 PData.ParentID = 0;
211 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
212 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
213 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
214 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
215 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
216 PData.PathTwist = addPacket.ObjectData.PathTwist;
217 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
218
219 return PData;
220 }
221 }
222}