From 5c7ffdde0b9642a42e8f5987e06eb01220ff7776 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 11 Jul 2007 08:02:47 +0000 Subject: * Wiping trunk in prep for Sugilite --- .../OpenSim.RegionServer/Client/ClientView.Grid.cs | 192 -------- .../Client/ClientView.PacketHandlers.cs | 196 -------- .../Client/ClientView.ProcessPackets.cs | 523 --------------------- OpenSim/OpenSim.RegionServer/Client/ClientView.cs | 461 ------------------ .../OpenSim.RegionServer/Client/ClientViewBase.cs | 326 ------------- 5 files changed, 1698 deletions(-) delete mode 100644 OpenSim/OpenSim.RegionServer/Client/ClientView.Grid.cs delete mode 100644 OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs delete mode 100644 OpenSim/OpenSim.RegionServer/Client/ClientView.ProcessPackets.cs delete mode 100644 OpenSim/OpenSim.RegionServer/Client/ClientView.cs delete mode 100644 OpenSim/OpenSim.RegionServer/Client/ClientViewBase.cs (limited to 'OpenSim/OpenSim.RegionServer/Client') diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientView.Grid.cs b/OpenSim/OpenSim.RegionServer/Client/ClientView.Grid.cs deleted file mode 100644 index 0bccbc2..0000000 --- a/OpenSim/OpenSim.RegionServer/Client/ClientView.Grid.cs +++ /dev/null @@ -1,192 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using Nwc.XmlRpc; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; -using OpenSim.RegionServer.Simulator; -using OpenSim.RegionServer.Assets; -using OpenSim.Framework.Console; - -namespace OpenSim.RegionServer.Client -{ - public partial class ClientView - { - - public void EnableNeighbours() - { - if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child)) - { - Hashtable SimParams; - ArrayList SendParams; - XmlRpcRequest GridReq; - XmlRpcResponse GridResp; - List enablePackets = new List(); - - RemoteGridBase gridServer = (RemoteGridBase)this.m_gridServer; - - foreach (Hashtable neighbour in gridServer.neighbours) - { - try - { - string neighbourIPStr = (string)neighbour["sim_ip"]; - System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse(neighbourIPStr); - ushort neighbourPort = (ushort)Convert.ToInt32(neighbour["sim_port"]); - string reqUrl = "http://" + neighbourIPStr + ":" + neighbourPort.ToString(); - - MainConsole.Instance.Verbose("Requesting " + reqUrl); - - SimParams = new Hashtable(); - SimParams["session_id"] = this.SessionID.ToString(); - SimParams["secure_session_id"] = this.SecureSessionID.ToString(); - SimParams["firstname"] = this.ClientAvatar.firstname; - SimParams["lastname"] = this.ClientAvatar.lastname; - SimParams["agent_id"] = this.AgentID.ToString(); - SimParams["circuit_code"] = (Int32)this.CircuitCode; - SimParams["child_agent"] = "1"; - SendParams = new ArrayList(); - SendParams.Add(SimParams); - - GridReq = new XmlRpcRequest("expect_user", SendParams); - GridResp = GridReq.Send(reqUrl, 3000); - EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); - enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); - enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256)); - - - byte[] byteIP = neighbourIP.GetAddressBytes(); - enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; - enablesimpacket.SimulatorInfo.Port = neighbourPort; - enablePackets.Add(enablesimpacket); - } - catch - { - MainConsole.Instance.Notice("Could not connect to neighbour " + neighbour["sim_ip"] + ":" + neighbour["sim_port"] + ", continuing."); - } - } - Thread.Sleep(3000); - foreach (Packet enable in enablePackets) - { - this.OutPacket(enable); - } - enablePackets.Clear(); - - } - } - - public void CrossSimBorder(LLVector3 avatarpos) - { // VERY VERY BASIC - - LLVector3 newpos = avatarpos; - uint neighbourx = this.m_regionData.RegionLocX; - uint neighboury = this.m_regionData.RegionLocY; - - if (avatarpos.X < 0) - { - neighbourx -= 1; - newpos.X = 254; - } - if (avatarpos.X > 255) - { - neighbourx += 1; - newpos.X = 1; - } - if (avatarpos.Y < 0) - { - neighboury -= 1; - newpos.Y = 254; - } - if (avatarpos.Y > 255) - { - neighboury += 1; - newpos.Y = 1; - } - MainConsole.Instance.Notice("SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]"); - - Hashtable SimParams; - ArrayList SendParams; - XmlRpcRequest GridReq; - XmlRpcResponse GridResp; - foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours) - { - if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString())) - { - SimParams = new Hashtable(); - SimParams["firstname"] = this.ClientAvatar.firstname; - SimParams["lastname"] = this.ClientAvatar.lastname; - SimParams["circuit_code"] = this.CircuitCode.ToString(); - SimParams["pos_x"] = newpos.X.ToString(); - SimParams["pos_y"] = newpos.Y.ToString(); - SimParams["pos_z"] = newpos.Z.ToString(); - SendParams = new ArrayList(); - SendParams.Add(SimParams); - - GridReq = new XmlRpcRequest("agent_crossing", SendParams); - GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000); - - CrossedRegionPacket NewSimPack = new CrossedRegionPacket(); - NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); - NewSimPack.AgentData.AgentID = this.AgentID; - NewSimPack.AgentData.SessionID = this.SessionID; - NewSimPack.Info = new CrossedRegionPacket.InfoBlock(); - NewSimPack.Info.Position = newpos; - NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! - NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); - NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256)); - System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]); - byte[] byteIP = neighbourIP.GetAddressBytes(); - NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; - NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; - NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; - NewSimPack.RegionData.SimIP += (uint)byteIP[0]; - NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]); - NewSimPack.RegionData.SeedCapability = new byte[0]; - lock (PacketQueue) - { - ProcessOutPacket(NewSimPack); - DowngradeClient(); - } - } - } - } - } -} diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs deleted file mode 100644 index 4af0485..0000000 --- a/OpenSim/OpenSim.RegionServer/Client/ClientView.PacketHandlers.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using Nwc.XmlRpc; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; -using OpenSim.RegionServer.Simulator; -using OpenSim.RegionServer.Assets; -using OpenSim.Framework.Console; - -namespace OpenSim.RegionServer.Client -{ - public partial class ClientView - { - protected virtual void RegisterLocalPacketHandlers() - { - this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); - this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); - this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); - } - - protected virtual bool Logout(ClientView simClient, Packet packet) - { - MainConsole.Instance.Notice("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); - //send reply to let the client logout - LogoutReplyPacket logReply = new LogoutReplyPacket(); - logReply.AgentData.AgentID = this.AgentID; - logReply.AgentData.SessionID = this.SessionID; - logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; - logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); - logReply.InventoryData[0].ItemID = LLUUID.Zero; - OutPacket(logReply); - //tell all clients to kill our object - KillObjectPacket kill = new KillObjectPacket(); - kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; - kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); - kill.ObjectData[0].ID = this.ClientAvatar.localid; - foreach (ClientView client in m_clientThreads.Values) - { - client.OutPacket(kill); - } - if (this.m_userServer != null) - { - this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); - } - else - { - this.m_inventoryCache.ClientLeaving(this.AgentID, null); - } - - m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); - /*lock (m_world.Entities) - { - m_world.Entities.Remove(this.AgentID); - }*/ - m_world.RemoveViewerAgent(this); - //need to do other cleaning up here too - m_clientThreads.Remove(this.CircuitCode); - m_networkServer.RemoveClientCircuit(this.CircuitCode); - this.ClientThread.Abort(); - return true; - } - - protected bool AgentTextureCached(ClientView simclient, Packet packet) - { - AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; - AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); - cachedresp.AgentData.AgentID = this.AgentID; - cachedresp.AgentData.SessionID = this.SessionID; - cachedresp.AgentData.SerialNum = this.cachedtextureserial; - this.cachedtextureserial++; - cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; - for (int i = 0; i < chechedtex.WearableData.Length; i++) - { - cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); - cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; - cachedresp.WearableData[i].TextureID = LLUUID.Zero; - cachedresp.WearableData[i].HostName = new byte[0]; - } - this.OutPacket(cachedresp); - return true; - } - - protected bool MultipleObjUpdate(ClientView simClient, Packet packet) - { - MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; - for (int i = 0; i < multipleupdate.ObjectData.Length; i++) - { - if (multipleupdate.ObjectData[i].Type == 9) //change position - { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); - OnUpdatePrimPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); - //should update stored position of the prim - } - else if (multipleupdate.ObjectData[i].Type == 10)//rotation - { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); - OnUpdatePrimRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); - } - else if (multipleupdate.ObjectData[i].Type == 13)//scale - { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); - OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); - } - } - return true; - } - - public void RequestMapLayer() //should be getting the map layer from the grid server - { - //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) - MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); - mapReply.AgentData.AgentID = this.AgentID; - mapReply.AgentData.Flags = 0; - mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; - mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); - mapReply.LayerData[0].Bottom = this.m_regionData.RegionLocY - 50; - mapReply.LayerData[0].Left = this.m_regionData.RegionLocX - 50; - mapReply.LayerData[0].Top = this.m_regionData.RegionLocY + 50; - mapReply.LayerData[0].Right = this.m_regionData.RegionLocX + 50; - mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000005"); - this.OutPacket(mapReply); - } - - public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) - { - IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); - int len; - if (simMapProfiles == null) - len = 0; - else - len = simMapProfiles.Count; - - int i; - int mtu = 24; // Number of regions to send per packet. Will be more precise in future. ( TODO ) - for (i = 0; i < len; i += mtu) - { - MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); - mbReply.AgentData.AgentID = this.AgentID; - - mbReply.Data = new MapBlockReplyPacket.DataBlock[Math.Min(mtu, len - i)]; - int j; - for (j = 0; (j < mtu) && ((i + j) < len); j++) - { - Hashtable mp = (Hashtable)simMapProfiles[j]; - mbReply.Data[j] = new MapBlockReplyPacket.DataBlock(); - mbReply.Data[j].Name = libsecondlife.Helpers.StringToField((string)mp["name"]); - mbReply.Data[j].Access = System.Convert.ToByte(mp["access"]); - mbReply.Data[j].Agents = System.Convert.ToByte(mp["agents"]); - mbReply.Data[j].MapImageID = new LLUUID((string)mp["map-image-id"]); - mbReply.Data[j].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); - mbReply.Data[j].WaterHeight = System.Convert.ToByte(mp["water-height"]); - mbReply.Data[j].X = System.Convert.ToUInt16(mp["x"]); - mbReply.Data[j].Y = System.Convert.ToUInt16(mp["y"]); - } - this.OutPacket(mbReply); - } - } - } -} diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/Client/ClientView.ProcessPackets.cs deleted file mode 100644 index 306bf63..0000000 --- a/OpenSim/OpenSim.RegionServer/Client/ClientView.ProcessPackets.cs +++ /dev/null @@ -1,523 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using Nwc.XmlRpc; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; -using OpenSim.RegionServer.Simulator; -using OpenSim.RegionServer.Assets; -using OpenSim.Framework.Console; - -namespace OpenSim.RegionServer.Client -{ - public partial class ClientView - { - public delegate void GenericCall(ClientView remoteClient); - public delegate void GenericCall2(); - public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary. - public delegate void GenericCall4(Packet packet, ClientView remoteClient); - public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock); - public delegate void ObjectSelect(uint localID, ClientView remoteClient); - public delegate void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient); - public delegate void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient); - public delegate void UpdatePrimVector(uint localID, LLVector3 pos, ClientView remoteClient); - public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient); - public delegate void StatusChange(bool status); - - - public event ChatFromViewer OnChatFromViewer; - public event RezObject OnRezObject; - public event GenericCall4 OnDeRezObject; - public event ModifyTerrain OnModifyTerrain; - public event GenericCall OnRegionHandShakeReply; - public event GenericCall OnRequestWearables; - public event SetAppearance OnSetAppearance; - public event GenericCall2 OnCompleteMovementToRegion; - public event GenericCall3 OnAgentUpdate; - public event StartAnim OnStartAnim; - public event GenericCall OnRequestAvatarsData; - public event LinkObjects OnLinkObjects; - public event GenericCall4 OnAddPrim; - public event UpdateShape OnUpdatePrimShape; - public event ObjectSelect OnObjectSelect; - public event UpdatePrimFlags OnUpdatePrimFlags; - public event UpdatePrimTexture OnUpdatePrimTexture; - public event UpdatePrimVector OnUpdatePrimPosition; - public event UpdatePrimRotation OnUpdatePrimRotation; - public event UpdatePrimVector OnUpdatePrimScale; - public event StatusChange OnChildAgentStatus; - - public event ParcelPropertiesRequest OnParcelPropertiesRequest; - public event ParcelDivideRequest OnParcelDivideRequest; - public event ParcelJoinRequest OnParcelJoinRequest; - public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; - - protected override void ProcessInPacket(Packet Pack) - { - ack_pack(Pack); - if (debug) - { - if (Pack.Type != PacketType.AgentUpdate) - { - Console.WriteLine("IN: " + Pack.Type.ToString()); - } - } - - - if (this.ProcessPacketMethod(Pack)) - { - //there is a handler registered that handled this packet type - return; - } - else - { - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - - switch (Pack.Type) - { - case PacketType.ViewerEffect: - ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; - foreach (ClientView client in m_clientThreads.Values) - { - if (client.AgentID != this.AgentID) - { - viewer.AgentData.AgentID = client.AgentID; - viewer.AgentData.SessionID = client.SessionID; - client.OutPacket(viewer); - } - } - break; - - #region New Event System - World/Avatar - case PacketType.ChatFromViewer: - ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; - if (Util.FieldToString(inchatpack.ChatData.Message) == "") - { - //empty message so don't bother with it - break; - } - string fromName = ClientAvatar.firstname + " " + ClientAvatar.lastname; - byte[] message = inchatpack.ChatData.Message; - byte type = inchatpack.ChatData.Type; - LLVector3 fromPos = ClientAvatar.Pos; - LLUUID fromAgentID = AgentID; - this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); - break; - case PacketType.RezObject: - RezObjectPacket rezPacket = (RezObjectPacket)Pack; - AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID); - if (inven != null) - { - if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) - { - AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); - if (asset != null) - { - this.OnRezObject(asset, rezPacket.RezData.RayEnd); - this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID); - } - } - } - break; - case PacketType.DeRezObject: - OnDeRezObject(Pack, this); - break; - case PacketType.ModifyLand: - ModifyLandPacket modify = (ModifyLandPacket)Pack; - if (modify.ParcelData.Length > 0) - { - OnModifyTerrain(modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); - } - break; - case PacketType.RegionHandshakeReply: - OnRegionHandShakeReply(this); - break; - case PacketType.AgentWearablesRequest: - OnRequestWearables(this); - OnRequestAvatarsData(this); - break; - case PacketType.AgentSetAppearance: - AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; - OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); - break; - case PacketType.CompleteAgentMovement: - if (this.m_child) this.UpgradeClient(); - OnCompleteMovementToRegion(); - this.EnableNeighbours(); - break; - case PacketType.AgentUpdate: - OnAgentUpdate(Pack); - break; - case PacketType.AgentAnimation: - if (!m_child) - { - AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; - for (int i = 0; i < AgentAni.AnimationList.Length; i++) - { - if (AgentAni.AnimationList[i].StartAnim) - { - OnStartAnim(AgentAni.AnimationList[i].AnimID, 1); - } - } - } - break; - - #endregion - - #region New Event System - Objects/Prims - case PacketType.ObjectLink: - ObjectLinkPacket link = (ObjectLinkPacket)Pack; - uint parentprimid = 0; - List childrenprims = new List(); - if (link.ObjectData.Length > 1) - { - parentprimid = link.ObjectData[0].ObjectLocalID; - - for (int i = 1; i < link.ObjectData.Length; i++) - { - childrenprims.Add(link.ObjectData[i].ObjectLocalID); - } - } - OnLinkObjects(parentprimid, childrenprims); - break; - case PacketType.ObjectAdd: - m_world.AddNewPrim((ObjectAddPacket)Pack, this); - OnAddPrim(Pack, this); - break; - case PacketType.ObjectShape: - ObjectShapePacket shape = (ObjectShapePacket)Pack; - for (int i = 0; i < shape.ObjectData.Length; i++) - { - OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]); - } - break; - case PacketType.ObjectSelect: - ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; - for (int i = 0; i < incomingselect.ObjectData.Length; i++) - { - OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); - } - break; - case PacketType.ObjectFlagUpdate: - ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; - OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); - break; - case PacketType.ObjectImage: - ObjectImagePacket imagePack = (ObjectImagePacket)Pack; - for (int i = 0; i < imagePack.ObjectData.Length; i++) - { - OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); - - } - break; - #endregion - - #region Inventory/Asset/Other related packets - case PacketType.RequestImage: - RequestImagePacket imageRequest = (RequestImagePacket)Pack; - for (int i = 0; i < imageRequest.RequestImage.Length; i++) - { - m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); - } - break; - case PacketType.TransferRequest: - TransferRequestPacket transfer = (TransferRequestPacket)Pack; - m_assetCache.AddAssetRequest(this, transfer); - break; - case PacketType.AssetUploadRequest: - AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; - this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); - break; - case PacketType.RequestXfer: - break; - case PacketType.SendXferPacket: - this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); - break; - case PacketType.CreateInventoryFolder: - CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; - m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); - break; - case PacketType.CreateInventoryItem: - CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; - if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) - { - this.UploadAssets.CreateInventoryItem(createItem); - } - else - { - this.CreateInventoryItem(createItem); - } - break; - case PacketType.FetchInventory: - FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; - m_inventoryCache.FetchInventory(this, FetchInventory); - break; - case PacketType.FetchInventoryDescendents: - FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - m_inventoryCache.FetchInventoryDescendents(this, Fetch); - break; - case PacketType.UpdateInventoryItem: - UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; - for (int i = 0; i < update.InventoryData.Length; i++) - { - if (update.InventoryData[i].TransactionID != LLUUID.Zero) - { - AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); - if (asset != null) - { - m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); - } - else - { - asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); - if (asset != null) - { - m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); - } - else - { - - } - } - } - else - { - m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; - } - } - break; - case PacketType.RequestTaskInventory: - RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; - ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); - bool foundent = false; - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == requesttask.InventoryData.LocalID) - { - replytask.InventoryData.TaskID = ent.uuid; - replytask.InventoryData.Serial = 0; - replytask.InventoryData.Filename = new byte[0]; - foundent = true; - } - } - if (foundent) - { - this.OutPacket(replytask); - } - break; - case PacketType.UpdateTaskInventory: - UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; - AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); - if (myinventory != null) - { - if (updatetask.UpdateData.Key == 0) - { - if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) - { - if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) - { - LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; - AssetBase assBase = this.m_assetCache.GetAsset(noteaid); - if (assBase != null) - { - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == updatetask.UpdateData.LocalID) - { - if (ent is OpenSim.RegionServer.Simulator.Primitive) - { - this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); - } - } - } - } - } - } - } - } - break; - case PacketType.MapLayerRequest: - // This be busted. - MapLayerRequestPacket MapRequest = (MapLayerRequestPacket)Pack; - this.RequestMapLayer(); - this.RequestMapBlocks((int)this.m_regionData.RegionLocX - 5, (int)this.m_regionData.RegionLocY - 5, (int)this.m_regionData.RegionLocX + 5, (int)this.m_regionData.RegionLocY + 5); - break; - - case PacketType.MapBlockRequest: - MapBlockRequestPacket MapBRequest = (MapBlockRequestPacket)Pack; - this.RequestMapBlocks(MapBRequest.PositionData.MinX, MapBRequest.PositionData.MinY, MapBRequest.PositionData.MaxX, MapBRequest.PositionData.MaxY); - break; - - case PacketType.MapNameRequest: - // TODO. - break; - - case PacketType.TeleportLandmarkRequest: - TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; - - TeleportStartPacket tpStart = new TeleportStartPacket(); - tpStart.Info.TeleportFlags = 8; // tp via lm - this.OutPacket(tpStart); - - TeleportProgressPacket tpProgress = new TeleportProgressPacket(); - tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark"); - tpProgress.Info.TeleportFlags = 8; - tpProgress.AgentData.AgentID = tpReq.Info.AgentID; - this.OutPacket(tpProgress); - - // Fetch landmark - LLUUID lmid = tpReq.Info.LandmarkID; - AssetBase lma = this.m_assetCache.GetAsset(lmid); - if (lma != null) - { - AssetLandmark lm = new AssetLandmark(lma); - - if (lm.RegionID == m_regionData.SimUUID) - { - TeleportLocalPacket tpLocal = new TeleportLocalPacket(); - - tpLocal.Info.AgentID = tpReq.Info.AgentID; - tpLocal.Info.TeleportFlags = 8; // Teleport via landmark - tpLocal.Info.LocationID = 2; - tpLocal.Info.Position = lm.Position; - OutPacket(tpLocal); - } - else - { - TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.AgentID = tpReq.Info.AgentID; - tpCancel.Info.SessionID = tpReq.Info.SessionID; - OutPacket(tpCancel); - } - } - else - { - Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); - - TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.AgentID = tpReq.Info.AgentID; - tpCancel.Info.SessionID = tpReq.Info.SessionID; - OutPacket(tpCancel); - } - break; - case PacketType.TeleportLocationRequest: - TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; - Console.WriteLine(tpLocReq.ToString()); - - tpStart = new TeleportStartPacket(); - tpStart.Info.TeleportFlags = 16; // Teleport via location - Console.WriteLine(tpStart.ToString()); - OutPacket(tpStart); - - if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle) - { - /* m_gridServer.getRegion(tpLocReq.Info.RegionHandle); */ - Console.WriteLine("Inter-sim teleport not yet implemented"); - TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; - tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; - - OutPacket(tpCancel); - } - else - { - Console.WriteLine("Local teleport"); - TeleportLocalPacket tpLocal = new TeleportLocalPacket(); - tpLocal.Info.AgentID = tpLocReq.AgentData.AgentID; - tpLocal.Info.TeleportFlags = tpStart.Info.TeleportFlags; - tpLocal.Info.LocationID = 2; - tpLocal.Info.LookAt = tpLocReq.Info.LookAt; - tpLocal.Info.Position = tpLocReq.Info.Position; - OutPacket(tpLocal); - - } - break; - #endregion - - #region Parcel Packets - case PacketType.ParcelPropertiesRequest: - ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; - OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North),propertiesRequest.ParcelData.SequenceID,propertiesRequest.ParcelData.SnapSelection, this); - break; - case PacketType.ParcelDivide: - ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack; - OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this); - break; - case PacketType.ParcelJoin: - ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack; - OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this); - break; - case PacketType.ParcelPropertiesUpdate: - ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; - OnParcelPropertiesUpdateRequest(updatePacket, this); - break; - #endregion - - #region Estate Packets - case PacketType.EstateOwnerMessage: - this.m_world.estateManager.handleEstateOwnerMessage((EstateOwnerMessagePacket)Pack, this); - break; - #endregion - #region unimplemented handlers - case PacketType.AgentIsNowWearing: - // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; - break; - case PacketType.ObjectScale: - break; - case PacketType.MoneyBalanceRequest: - //This need to be actually done and not thrown back with fake infos - break; - - case PacketType.EstateCovenantRequest: - //This should be actually done and not thrown back with fake info - EstateCovenantRequestPacket estateCovenantRequest = (EstateCovenantRequestPacket)Pack; - EstateCovenantReplyPacket estateCovenantReply = new EstateCovenantReplyPacket(); - estateCovenantReply.Data.EstateName = libsecondlife.Helpers.StringToField("Leet Estate"); - estateCovenantReply.Data.EstateOwnerID = LLUUID.Zero; - estateCovenantReply.Data.CovenantID = LLUUID.Zero; - estateCovenantReply.Data.CovenantTimestamp = (uint)0; - this.OutPacket((Packet)estateCovenantReply); - MainConsole.Instance.Notice("Sent Temporary Estate packet (they are in leet estate)"); - break; - #endregion - } - } - } - } -} diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientView.cs b/OpenSim/OpenSim.RegionServer/Client/ClientView.cs deleted file mode 100644 index 29efcc9..0000000 --- a/OpenSim/OpenSim.RegionServer/Client/ClientView.cs +++ /dev/null @@ -1,461 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using Nwc.XmlRpc; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Utilities; -using OpenSim.RegionServer.Simulator; -using OpenSim.RegionServer.Assets; -using OpenSim.Framework.Console; - -namespace OpenSim.RegionServer.Client -{ - public delegate bool PacketMethod(ClientView simClient, Packet packet); - - /// - /// Handles new client connections - /// Constructor takes a single Packet and authenticates everything - /// - public partial class ClientView : ClientViewBase, IClientAPI - { - protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients - protected Dictionary m_packetHandlers = new Dictionary(); //local handlers for this instance - - public LLUUID AgentID; - public LLUUID SessionID; - public LLUUID SecureSessionID = LLUUID.Zero; - public bool m_child; - public Simulator.Avatar ClientAvatar; - private UseCircuitCodePacket cirpack; - public Thread ClientThread; - public LLVector3 startpos; - - private AgentAssetUpload UploadAssets; - private LLUUID newAssetFolder = LLUUID.Zero; - private bool debug = false; - private World m_world; - private Dictionary m_clientThreads; - private AssetCache m_assetCache; - private IGridServer m_gridServer; - private IUserServer m_userServer = null; - private InventoryCache m_inventoryCache; - public bool m_sandboxMode; - private int cachedtextureserial = 0; - private RegionInfo m_regionData; - protected AuthenticateSessionsBase m_authenticateSessionsHandler; - - public IUserServer UserServer - { - set - { - this.m_userServer = value; - } - } - - public LLVector3 StartPos - { - get - { - return startpos; - } - set - { - startpos = value; - } - } - - public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions) - { - m_world = world; - m_clientThreads = clientThreads; - m_assetCache = assetCache; - m_gridServer = gridServer; - m_networkServer = application; - m_inventoryCache = inventoryCache; - m_sandboxMode = sandboxMode; - m_child = child; - m_regionData = regionDat; - m_authenticateSessionsHandler = authenSessions; - MainConsole.Instance.Notice("OpenSimClient.cs - Started up new client thread to handle incoming request"); - cirpack = initialcirpack; - userEP = remoteEP; - - if (m_gridServer.GetName() == "Remote") - { - this.m_child = m_authenticateSessionsHandler.GetAgentChildStatus(initialcirpack.CircuitCode.Code); - this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); - - // Dont rez new users underground - float aboveGround = 3.0f; // rez at least 3 meters above ground - if (this.startpos.Z < (m_world.Terrain[(int)this.startpos.X, (int)this.startpos.Y] + aboveGround)) - this.startpos.Z = m_world.Terrain[(int)this.startpos.X, (int)this.startpos.Y] + aboveGround; - - } - else - { - this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 15.0f); // new LLVector3(128.0f, 128.0f, 60f); - } - - PacketQueue = new BlockingQueue(); - - this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); - AckTimer = new System.Timers.Timer(500); - AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); - AckTimer.Start(); - - this.RegisterLocalPacketHandlers(); - - - - ClientThread = new Thread(new ThreadStart(AuthUser)); - ClientThread.IsBackground = true; - ClientThread.Start(); - } - - # region Client Methods - public void UpgradeClient() - { - MainConsole.Instance.Notice("SimClient.cs:UpgradeClient() - upgrading child to full agent"); - this.m_child = false; - //this.m_world.RemoveViewerAgent(this); - if (!this.m_sandboxMode) - { - this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode); - m_authenticateSessionsHandler.UpdateAgentChildStatus(CircuitCode, false); - } - OnChildAgentStatus(this.m_child); - //this.InitNewClient(); - } - - public void DowngradeClient() - { - MainConsole.Instance.Notice("SimClient.cs:UpgradeClient() - changing full agent to child"); - this.m_child = true; - OnChildAgentStatus(this.m_child); - //this.m_world.RemoveViewerAgent(this); - //this.m_world.AddViewerAgent(this); - } - - public void KillClient() - { - KillObjectPacket kill = new KillObjectPacket(); - kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; - kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); - kill.ObjectData[0].ID = this.ClientAvatar.localid; - foreach (ClientView client in m_clientThreads.Values) - { - client.OutPacket(kill); - } - if (this.m_userServer != null) - { - this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); - } - else - { - this.m_inventoryCache.ClientLeaving(this.AgentID, null); - } - - m_world.RemoveViewerAgent(this); - - m_clientThreads.Remove(this.CircuitCode); - m_networkServer.RemoveClientCircuit(this.CircuitCode); - this.ClientThread.Abort(); - } - #endregion - - # region Packet Handling - public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) - { - bool result = false; - lock (PacketHandlers) - { - if (!PacketHandlers.ContainsKey(packetType)) - { - PacketHandlers.Add(packetType, handler); - result = true; - } - } - return result; - } - - public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) - { - bool result = false; - lock (m_packetHandlers) - { - if (!m_packetHandlers.ContainsKey(packetType)) - { - m_packetHandlers.Add(packetType, handler); - result = true; - } - } - return result; - } - - protected virtual bool ProcessPacketMethod(Packet packet) - { - bool result = false; - bool found = false; - PacketMethod method; - if (m_packetHandlers.TryGetValue(packet.Type, out method)) - { - //there is a local handler for this packet type - result = method(this, packet); - } - else - { - //there is not a local handler so see if there is a Global handler - lock (PacketHandlers) - { - found = PacketHandlers.TryGetValue(packet.Type, out method); - } - if (found) - { - result = method(this, packet); - } - } - return result; - } - - protected virtual void ClientLoop() - { - MainConsole.Instance.Notice("OpenSimClient.cs:ClientLoop() - Entered loop"); - while (true) - { - QueItem nextPacket = PacketQueue.Dequeue(); - if (nextPacket.Incoming) - { - //is a incoming packet - ProcessInPacket(nextPacket.Packet); - } - else - { - //is a out going packet - ProcessOutPacket(nextPacket.Packet); - } - } - } - # endregion - - # region Setup - - protected virtual void InitNewClient() - { - MainConsole.Instance.Notice("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); - this.ClientAvatar = m_world.AddViewerAgent(this); - } - - protected virtual void AuthUser() - { - // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); - AuthenticateResponse sessionInfo = this.m_networkServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); - if (!sessionInfo.Authorised) - { - //session/circuit not authorised - OpenSim.Framework.Console.MainConsole.Instance.Notice("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); - ClientThread.Abort(); - } - else - { - OpenSim.Framework.Console.MainConsole.Instance.Notice("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); - //session is authorised - this.AgentID = cirpack.CircuitCode.ID; - this.SessionID = cirpack.CircuitCode.SessionID; - this.CircuitCode = cirpack.CircuitCode.Code; - InitNewClient(); - this.ClientAvatar.firstname = sessionInfo.LoginInfo.First; - this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last; - if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) - { - this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; - } - - // Create Inventory, currently only works for sandbox mode - if (m_sandboxMode) - { - this.SetupInventory(sessionInfo); - } - - //m_world.parcelManager.sendParcelOverlay(this); - m_world.estateManager.sendRegionInfoPacket(this); - - ClientLoop(); - } - } - # endregion - - - protected override void KillThread() - { - this.ClientThread.Abort(); - } - - #region World/Avatar To Viewer Methods - - public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) - { - System.Text.Encoding enc = System.Text.Encoding.ASCII; - libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); - reply.ChatData.Audible = 1; - reply.ChatData.Message = message; - reply.ChatData.ChatType = type; - reply.ChatData.SourceType = 1; - reply.ChatData.Position = fromPos; - reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); - reply.ChatData.OwnerID = fromAgentID; - reply.ChatData.SourceID = fromAgentID; - - this.OutPacket(reply); - } - - public void SendAppearance(AvatarWearable[] wearables) - { - AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.AgentID; - aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = this.SessionID; - - aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; - AgentWearablesUpdatePacket.WearableDataBlock awb; - for (int i = 0; i < wearables.Length; i++) - { - awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; - awb.AssetID = wearables[i].AssetID; - awb.ItemID = wearables[i].ItemID; - aw.WearableData[i] = awb; - } - - this.OutPacket(aw); - } - #endregion - - #region Inventory Creation - private void SetupInventory(AuthenticateResponse sessionInfo) - { - AgentInventory inventory = null; - if (sessionInfo.LoginInfo.InventoryFolder != null) - { - inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); - if (sessionInfo.LoginInfo.BaseFolder != null) - { - if (!inventory.HasFolder(sessionInfo.LoginInfo.BaseFolder)) - { - m_inventoryCache.CreateNewInventoryFolder(this, sessionInfo.LoginInfo.BaseFolder); - } - this.newAssetFolder = sessionInfo.LoginInfo.BaseFolder; - AssetBase[] inventorySet = m_assetCache.CreateNewInventorySet(this.AgentID); - if (inventorySet != null) - { - for (int i = 0; i < inventorySet.Length; i++) - { - if (inventorySet[i] != null) - { - m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); - } - } - } - } - } - } - private AgentInventory CreateInventory(LLUUID baseFolder) - { - AgentInventory inventory = null; - if (this.m_userServer != null) - { - // a user server is set so request the inventory from it - MainConsole.Instance.Verbose("getting inventory from user server"); - inventory = m_inventoryCache.FetchAgentsInventory(this.AgentID, m_userServer); - } - else - { - inventory = new AgentInventory(); - inventory.AgentID = this.AgentID; - inventory.CreateRootFolder(this.AgentID, false); - m_inventoryCache.AddNewAgentsInventory(inventory); - m_inventoryCache.CreateNewInventoryFolder(this, baseFolder); - } - return inventory; - } - - private void CreateInventoryItem(CreateInventoryItemPacket packet) - { - if (!(packet.InventoryBlock.Type == 3 || packet.InventoryBlock.Type == 7)) - { - MainConsole.Instance.Warn("Attempted to create " + Util.FieldToString(packet.InventoryBlock.Name) + " in inventory. Unsupported type"); - return; - } - - //lets try this out with creating a notecard - AssetBase asset = new AssetBase(); - - asset.Name = Util.FieldToString(packet.InventoryBlock.Name); - asset.Description = Util.FieldToString(packet.InventoryBlock.Description); - asset.InvType = packet.InventoryBlock.InvType; - asset.Type = packet.InventoryBlock.Type; - asset.FullID = LLUUID.Random(); - - switch (packet.InventoryBlock.Type) - { - case 7: // Notecard - asset.Data = new byte[0]; - break; - - case 3: // Landmark - String content; - content = "Landmark version 2\n"; - content += "region_id " + m_regionData.SimUUID + "\n"; - String strPos = String.Format("%.2f %.2f %.2f>", - this.ClientAvatar.Pos.X, - this.ClientAvatar.Pos.Y, - this.ClientAvatar.Pos.Z); - content += "local_pos " + strPos + "\n"; - asset.Data = (new System.Text.ASCIIEncoding()).GetBytes(content); - break; - default: - break; - } - m_assetCache.AddAsset(asset); - m_inventoryCache.AddNewInventoryItem(this, packet.InventoryBlock.FolderID, asset); - } - #endregion - - } -} diff --git a/OpenSim/OpenSim.RegionServer/Client/ClientViewBase.cs b/OpenSim/OpenSim.RegionServer/Client/ClientViewBase.cs deleted file mode 100644 index 2ff245f..0000000 --- a/OpenSim/OpenSim.RegionServer/Client/ClientViewBase.cs +++ /dev/null @@ -1,326 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Console; - -namespace OpenSim.RegionServer.Client -{ - public class ClientViewBase - { - protected BlockingQueue PacketQueue; - protected Dictionary PendingAcks = new Dictionary(); - protected Dictionary NeedAck = new Dictionary(); - - protected System.Timers.Timer AckTimer; - protected uint Sequence = 0; - protected object SequenceLock = new object(); - protected const int MAX_APPENDED_ACKS = 10; - protected const int RESEND_TIMEOUT = 4000; - protected const int MAX_SEQUENCE = 0xFFFFFF; - - public uint CircuitCode; - public EndPoint userEP; - - protected OpenSimNetworkHandler m_networkServer; - - public ClientViewBase() - { - - } - - protected virtual void ProcessInPacket(Packet Pack) - { - - } - - protected virtual void ProcessOutPacket(Packet Pack) - { - // Keep track of when this packet was sent out - Pack.TickCount = Environment.TickCount; - - - if (!Pack.Header.Resent) - { - // Set the sequence number - lock (SequenceLock) - { - if (Sequence >= MAX_SEQUENCE) - Sequence = 1; - else - Sequence++; - Pack.Header.Sequence = Sequence; - } - - if (Pack.Header.Reliable) //DIRTY HACK - { - lock (NeedAck) - { - if (!NeedAck.ContainsKey(Pack.Header.Sequence)) - { - try - { - NeedAck.Add(Pack.Header.Sequence, Pack); - } - catch (Exception e) // HACKY - { - e.ToString(); - // Ignore - // Seems to throw a exception here occasionally - // of 'duplicate key' despite being locked. - // !?!?!? - } - } - else - { - // Client.Log("Attempted to add a duplicate sequence number (" + - // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + - // packet.Type.ToString(), Helpers.LogLevel.Warning); - } - } - - // Don't append ACKs to resent packets, in case that's what was causing the - // delivery to fail - if (!Pack.Header.Resent) - { - // Append any ACKs that need to be sent out to this packet - lock (PendingAcks) - { - if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && - Pack.Type != PacketType.PacketAck && - Pack.Type != PacketType.LogoutRequest) - { - Pack.Header.AckList = new uint[PendingAcks.Count]; - int i = 0; - - foreach (uint ack in PendingAcks.Values) - { - Pack.Header.AckList[i] = ack; - i++; - } - - PendingAcks.Clear(); - Pack.Header.AppendedAcks = true; - } - } - } - } - } - - byte[] ZeroOutBuffer = new byte[4096]; - byte[] sendbuffer; - sendbuffer = Pack.ToBytes(); - - try - { - if (Pack.Header.Zerocoded) - { - int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); - } - else - { - m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); - } - } - catch (Exception) - { - MainConsole.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); - this.KillThread(); - } - - } - - public virtual void InPacket(Packet NewPack) - { - // Handle appended ACKs - if (NewPack.Header.AppendedAcks) - { - lock (NeedAck) - { - foreach (uint ack in NewPack.Header.AckList) - { - NeedAck.Remove(ack); - } - } - } - - // Handle PacketAck packets - if (NewPack.Type == PacketType.PacketAck) - { - PacketAckPacket ackPacket = (PacketAckPacket)NewPack; - - lock (NeedAck) - { - foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) - { - NeedAck.Remove(block.ID); - } - } - } - else if ((NewPack.Type == PacketType.StartPingCheck)) - { - //reply to pingcheck - libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; - libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); - endPing.PingID.PingID = startPing.PingID.PingID; - OutPacket(endPing); - } - else - { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = true; - this.PacketQueue.Enqueue(item); - } - - } - - public virtual void OutPacket(Packet NewPack) - { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = false; - this.PacketQueue.Enqueue(item); - } - - # region Low Level Packet Methods - - protected void ack_pack(Packet Pack) - { - if (Pack.Header.Reliable) - { - libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); - ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; - ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); - ack_it.Packets[0].ID = Pack.Header.Sequence; - ack_it.Header.Reliable = false; - - OutPacket(ack_it); - - } - /* - if (Pack.Header.Reliable) - { - lock (PendingAcks) - { - uint sequence = (uint)Pack.Header.Sequence; - if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } - } - }*/ - } - - protected void ResendUnacked() - { - int now = Environment.TickCount; - - lock (NeedAck) - { - foreach (Packet packet in NeedAck.Values) - { - if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) - { - OpenSim.Framework.Console.MainConsole.Instance.Verbose("Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); - - packet.Header.Resent = true; - OutPacket(packet); - } - } - } - } - - protected void SendAcks() - { - lock (PendingAcks) - { - if (PendingAcks.Count > 0) - { - if (PendingAcks.Count > 250) - { - // FIXME: Handle the odd case where we have too many pending ACKs queued up - OpenSim.Framework.Console.MainConsole.Instance.Verbose("Too many ACKs queued up!"); - return; - } - - - int i = 0; - PacketAckPacket acks = new PacketAckPacket(); - acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; - - foreach (uint ack in PendingAcks.Values) - { - acks.Packets[i] = new PacketAckPacket.PacketsBlock(); - acks.Packets[i].ID = ack; - i++; - } - - acks.Header.Reliable = false; - OutPacket(acks); - - PendingAcks.Clear(); - } - } - } - - protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) - { - SendAcks(); - ResendUnacked(); - } - #endregion - - protected virtual void KillThread() - { - - } - - #region Nested Classes - - public class QueItem - { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - #endregion - } -} -- cgit v1.1