aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs
diff options
context:
space:
mode:
authormingchen2007-06-07 14:23:19 +0000
committermingchen2007-06-07 14:23:19 +0000
commitf88a4777f9e9b23795aed5a7f364a93a73e9ed15 (patch)
tree7acf567aed35932ae0bcc5410698379bbb6087c0 /OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs
parent*When avatar crosses parcel, it updates successfully in the viewer (diff)
downloadopensim-SC_OLD-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.zip
opensim-SC_OLD-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.gz
opensim-SC_OLD-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.bz2
opensim-SC_OLD-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.xz
*Cleaned up namespaces, filenames, etc in OpenSim.RegionServer
NOTES: *ClientView is now in the namespace OpenSim.RegionServer.Client *Scripting is now in the namespace OpenSim.RegionServer.scripting *Other various cleaning
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs196
1 files changed, 196 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..4af0485
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs
@@ -0,0 +1,196 @@
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.RegionServer.Simulator;
44using OpenSim.RegionServer.Assets;
45using OpenSim.Framework.Console;
46
47namespace OpenSim.RegionServer.Client
48{
49 public partial class ClientView
50 {
51 protected virtual void RegisterLocalPacketHandlers()
52 {
53 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
54 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
55 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
56 }
57
58 protected virtual bool Logout(ClientView simClient, Packet packet)
59 {
60 MainConsole.Instance.Notice("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
61 //send reply to let the client logout
62 LogoutReplyPacket logReply = new LogoutReplyPacket();
63 logReply.AgentData.AgentID = this.AgentID;
64 logReply.AgentData.SessionID = this.SessionID;
65 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
66 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
67 logReply.InventoryData[0].ItemID = LLUUID.Zero;
68 OutPacket(logReply);
69 //tell all clients to kill our object
70 KillObjectPacket kill = new KillObjectPacket();
71 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
72 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
73 kill.ObjectData[0].ID = this.ClientAvatar.localid;
74 foreach (ClientView client in m_clientThreads.Values)
75 {
76 client.OutPacket(kill);
77 }
78 if (this.m_userServer != null)
79 {
80 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
81 }
82 else
83 {
84 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
85 }
86
87 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
88 /*lock (m_world.Entities)
89 {
90 m_world.Entities.Remove(this.AgentID);
91 }*/
92 m_world.RemoveViewerAgent(this);
93 //need to do other cleaning up here too
94 m_clientThreads.Remove(this.CircuitCode);
95 m_networkServer.RemoveClientCircuit(this.CircuitCode);
96 this.ClientThread.Abort();
97 return true;
98 }
99
100 protected bool AgentTextureCached(ClientView simclient, Packet packet)
101 {
102 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
103 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
104 cachedresp.AgentData.AgentID = this.AgentID;
105 cachedresp.AgentData.SessionID = this.SessionID;
106 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
107 this.cachedtextureserial++;
108 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
109 for (int i = 0; i < chechedtex.WearableData.Length; i++)
110 {
111 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
112 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
113 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
114 cachedresp.WearableData[i].HostName = new byte[0];
115 }
116 this.OutPacket(cachedresp);
117 return true;
118 }
119
120 protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
121 {
122 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
123 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
124 {
125 if (multipleupdate.ObjectData[i].Type == 9) //change position
126 {
127 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
128 OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
129 //should update stored position of the prim
130 }
131 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
132 {
133 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
134 OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
135 }
136 else if (multipleupdate.ObjectData[i].Type == 13)//scale
137 {
138 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
139 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
140 }
141 }
142 return true;
143 }
144
145 public void RequestMapLayer() //should be getting the map layer from the grid server
146 {
147 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
148 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
149 mapReply.AgentData.AgentID = this.AgentID;
150 mapReply.AgentData.Flags = 0;
151 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
152 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
153 mapReply.LayerData[0].Bottom = this.m_regionData.RegionLocY - 50;
154 mapReply.LayerData[0].Left = this.m_regionData.RegionLocX - 50;
155 mapReply.LayerData[0].Top = this.m_regionData.RegionLocY + 50;
156 mapReply.LayerData[0].Right = this.m_regionData.RegionLocX + 50;
157 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000005");
158 this.OutPacket(mapReply);
159 }
160
161 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
162 {
163 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
164 int len;
165 if (simMapProfiles == null)
166 len = 0;
167 else
168 len = simMapProfiles.Count;
169
170 int i;
171 int mtu = 24; // Number of regions to send per packet. Will be more precise in future. ( TODO )
172 for (i = 0; i < len; i += mtu)
173 {
174 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
175 mbReply.AgentData.AgentID = this.AgentID;
176
177 mbReply.Data = new MapBlockReplyPacket.DataBlock[Math.Min(mtu, len - i)];
178 int j;
179 for (j = 0; (j < mtu) && ((i + j) < len); j++)
180 {
181 Hashtable mp = (Hashtable)simMapProfiles[j];
182 mbReply.Data[j] = new MapBlockReplyPacket.DataBlock();
183 mbReply.Data[j].Name = libsecondlife.Helpers.StringToField((string)mp["name"]);
184 mbReply.Data[j].Access = System.Convert.ToByte(mp["access"]);
185 mbReply.Data[j].Agents = System.Convert.ToByte(mp["agents"]);
186 mbReply.Data[j].MapImageID = new LLUUID((string)mp["map-image-id"]);
187 mbReply.Data[j].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
188 mbReply.Data[j].WaterHeight = System.Convert.ToByte(mp["water-height"]);
189 mbReply.Data[j].X = System.Convert.ToUInt16(mp["x"]);
190 mbReply.Data[j].Y = System.Convert.ToUInt16(mp["y"]);
191 }
192 this.OutPacket(mbReply);
193 }
194 }
195 }
196}