aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:16:50 +0000
committerMW2007-05-24 12:16:50 +0000
commit3376b82501000692d6dac24b051af738cdaf2737 (patch)
tree90ed0a5d4955236f011fa63fce9d555186b0d179 /OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs
parentAdded "terrain save grdmap <filename> <gradientmap>" function to console. Gra... (diff)
downloadopensim-SC-3376b82501000692d6dac24b051af738cdaf2737.zip
opensim-SC-3376b82501000692d6dac24b051af738cdaf2737.tar.gz
opensim-SC-3376b82501000692d6dac24b051af738cdaf2737.tar.bz2
opensim-SC-3376b82501000692d6dac24b051af738cdaf2737.tar.xz
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs')
-rw-r--r--OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs163
1 files changed, 163 insertions, 0 deletions
diff --git a/OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs
new file mode 100644
index 0000000..75fcf18
--- /dev/null
+++ b/OpenSim-Source/OpenSim.RegionServer/ClientView.PacketHandlers.cs
@@ -0,0 +1,163 @@
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 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 OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
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 OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
108 }
109 else if (multipleupdate.ObjectData[i].Type == 13)//scale
110 {
111 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
112 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
113 }
114 }
115 return true;
116 }
117
118 public void RequestMapLayer() //should be getting the map layer from the grid server
119 {
120 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
121 MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
122 mapReply.AgentData.AgentID = this.AgentID;
123 mapReply.AgentData.Flags = 0;
124 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
125 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
126 mapReply.LayerData[0].Bottom = 800;
127 mapReply.LayerData[0].Left = 800;
128 mapReply.LayerData[0].Top = 1200;
129 mapReply.LayerData[0].Right = 1200;
130 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
131 this.OutPacket(mapReply);
132 }
133
134 public void RequestMapBlocks(int minX, int minY, int maxX, int maxY)
135 {
136 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
137 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
138 mbReply.AgentData.AgentID = this.AgentID;
139 int len;
140 if (simMapProfiles == null)
141 len = 0;
142 else
143 len = simMapProfiles.Count;
144
145 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
146 int iii;
147 for (iii = 0; iii < len; iii++)
148 {
149 Hashtable mp = (Hashtable)simMapProfiles[iii];
150 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
151 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
152 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
153 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
154 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
155 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
156 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
157 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
158 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
159 }
160 this.OutPacket(mbReply);
161 }
162 }
163}