diff options
Diffstat (limited to 'OpenSim.RegionServer/ClientView.PacketHandlers.cs')
-rw-r--r-- | OpenSim.RegionServer/ClientView.PacketHandlers.cs | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim.RegionServer/ClientView.PacketHandlers.cs new file mode 100644 index 0000000..070c200 --- /dev/null +++ b/OpenSim.RegionServer/ClientView.PacketHandlers.cs | |||
@@ -0,0 +1,184 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using Nwc.XmlRpc; | ||
7 | using System.Net; | ||
8 | using System.Net.Sockets; | ||
9 | using System.IO; | ||
10 | using System.Threading; | ||
11 | using System.Timers; | ||
12 | using OpenSim.Framework.Interfaces; | ||
13 | using OpenSim.Framework.Types; | ||
14 | using OpenSim.Framework.Inventory; | ||
15 | using OpenSim.Framework.Utilities; | ||
16 | using OpenSim.world; | ||
17 | using OpenSim.Assets; | ||
18 | |||
19 | namespace OpenSim | ||
20 | { | ||
21 | public partial class ClientView | ||
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(ClientView 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 (ClientView 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(ClientView 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(ClientView 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 | } | ||