aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/SimClient.PacketHandlers.cs
diff options
context:
space:
mode:
authorMW2007-05-21 16:06:58 +0000
committerMW2007-05-21 16:06:58 +0000
commitfe46b045f75dec5ecdd0a29273c70df3e6ea540e (patch)
tree554c0fb47e513fc6a89f496d99b7b67de24edde7 /OpenSim.RegionServer/SimClient.PacketHandlers.cs
parentIncreased version number to 0.2! ZOMG! (diff)
downloadopensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.zip
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.gz
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.bz2
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.xz
Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim , switching to a event based system (World/Avatar register as event handlers). It is possible that I've broke something with this commit but it doesn't matter as I'll just hide and no one will find me.
Diffstat (limited to 'OpenSim.RegionServer/SimClient.PacketHandlers.cs')
-rw-r--r--OpenSim.RegionServer/SimClient.PacketHandlers.cs184
1 files changed, 0 insertions, 184 deletions
diff --git a/OpenSim.RegionServer/SimClient.PacketHandlers.cs b/OpenSim.RegionServer/SimClient.PacketHandlers.cs
deleted file mode 100644
index 62919ba..0000000
--- a/OpenSim.RegionServer/SimClient.PacketHandlers.cs
+++ /dev/null
@@ -1,184 +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 SimClient
22 {
23 protected virtual void RegisterLocalPacketHandlers()
24 {
25 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
26 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
27 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
28 }
29
30 protected virtual bool Logout(SimClient simClient, Packet packet)
31 {
32 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
33 //send reply to let the client logout
34 LogoutReplyPacket logReply = new LogoutReplyPacket();
35 logReply.AgentData.AgentID = this.AgentID;
36 logReply.AgentData.SessionID = this.SessionID;
37 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
38 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
39 logReply.InventoryData[0].ItemID = LLUUID.Zero;
40 OutPacket(logReply);
41 //tell all clients to kill our object
42 KillObjectPacket kill = new KillObjectPacket();
43 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
44 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
45 kill.ObjectData[0].ID = this.ClientAvatar.localid;
46 foreach (SimClient client in m_clientThreads.Values)
47 {
48 client.OutPacket(kill);
49 }
50 if (this.m_userServer != null)
51 {
52 this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
53 }
54 else
55 {
56 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
57 }
58
59 m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
60 /*lock (m_world.Entities)
61 {
62 m_world.Entities.Remove(this.AgentID);
63 }*/
64 m_world.RemoveViewerAgent(this);
65 //need to do other cleaning up here too
66 m_clientThreads.Remove(this.CircuitCode);
67 m_networkServer.RemoveClientCircuit(this.CircuitCode);
68 this.ClientThread.Abort();
69 return true;
70 }
71
72 protected bool AgentTextureCached(SimClient simclient, Packet packet)
73 {
74 // Console.WriteLine(packet.ToString());
75 AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
76 AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
77 cachedresp.AgentData.AgentID = this.AgentID;
78 cachedresp.AgentData.SessionID = this.SessionID;
79 cachedresp.AgentData.SerialNum = this.cachedtextureserial;
80 this.cachedtextureserial++;
81 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length];
82 for (int i = 0; i < chechedtex.WearableData.Length; i++)
83 {
84 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
85 cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex;
86 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
87 cachedresp.WearableData[i].HostName = new byte[0];
88 }
89 this.OutPacket(cachedresp);
90 return true;
91 }
92
93 protected bool MultipleObjUpdate(SimClient simClient, Packet packet)
94 {
95 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
96 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
97 {
98 if (multipleupdate.ObjectData[i].Type == 9) //change position
99 {
100 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
101 foreach (Entity ent in m_world.Entities.Values)
102 {
103 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
104 {
105 ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
106
107 }
108 }
109 //should update stored position of the prim
110 }
111 else if (multipleupdate.ObjectData[i].Type == 10)//rotation
112 {
113 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
114 foreach (Entity ent in m_world.Entities.Values)
115 {
116 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
117 {
118 ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
119 ((OpenSim.world.Primitive)ent).UpdateFlag = true;
120 }
121 }
122 }
123 else if (multipleupdate.ObjectData[i].Type == 13)//scale
124 {
125
126 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
127 foreach (Entity ent in m_world.Entities.Values)
128 {
129 if (ent.localid == multipleupdate.ObjectData[i].ObjectLocalID)
130 {
131 ((OpenSim.world.Primitive)ent).Scale = scale;
132 }
133 }
134 }
135 }
136 return true;
137 }
138
139 public void RequestMapLayer() //should be getting the map layer from the grid server
140 {
141 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
142 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
143 mapReply.AgentData.AgentID = this.AgentID;
144 mapReply.AgentData.Flags = 0;
145 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
146 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
147 mapReply.LayerData[0].Bottom = 800;
148 mapReply.LayerData[0].Left = 800;
149 mapReply.LayerData[0].Top = 1200;
150 mapReply.LayerData[0].Right = 1200;
151 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
152 this.OutPacket(mapReply);
153 }
154
155 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
156 {
157 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
158 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
159 mbReply.AgentData.AgentID = this.AgentID;
160 int len;
161 if (simMapProfiles == null)
162 len = 0;
163 else
164 len = simMapProfiles.Count;
165
166 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
167 int iii;
168 for (iii = 0; iii < len; iii++)
169 {
170 Hashtable mp = (Hashtable)simMapProfiles[iii];
171 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
172 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
173 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
174 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
175 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
176 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
177 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
178 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
179 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
180 }
181 this.OutPacket(mbReply);
182 }
183 }
184}