From 3f39648605a432aae6a8c9ff9fb5ee481b06035e Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 16 May 2007 15:46:22 +0000 Subject: More refactoring. Changed AuthenticateSession handling, now calls a method in UDPServer. (but is likely to change again soon) --- OpenSim.RegionServer/OpenSim.RegionServer.csproj | 12 + .../OpenSim.RegionServer.dll.build | 1 + OpenSim.RegionServer/OpenSim.csproj | 186 --------- OpenSim.RegionServer/OpenSim.exe.build | 69 ---- OpenSim.RegionServer/OpenSimMain.cs | 2 +- OpenSim.RegionServer/OpenSimNetworkHandler.cs | 3 + OpenSim.RegionServer/SimClient.PacketHandlers.cs | 2 +- OpenSim.RegionServer/SimClient.ProcessPackets.cs | 417 +++++++++++++++++++ OpenSim.RegionServer/SimClient.cs | 456 ++------------------- OpenSim.RegionServer/UDPServer.cs | 9 + 10 files changed, 479 insertions(+), 678 deletions(-) delete mode 100644 OpenSim.RegionServer/OpenSim.csproj delete mode 100644 OpenSim.RegionServer/OpenSim.exe.build create mode 100644 OpenSim.RegionServer/SimClient.ProcessPackets.cs (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 3c18bb6..8b23336 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -150,16 +150,24 @@ Code + SimClient.cs Code + SimClient.cs + + Code + SimClient.cs + + Code Code + Code @@ -180,12 +188,14 @@ Code + Avatar.cs Code Code + Avatar.cs Code @@ -207,9 +217,11 @@ Code + World.cs Code + World.cs Code diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index ab21d7e..25f4b60 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build @@ -21,6 +21,7 @@ + diff --git a/OpenSim.RegionServer/OpenSim.csproj b/OpenSim.RegionServer/OpenSim.csproj deleted file mode 100644 index 035f3e0..0000000 --- a/OpenSim.RegionServer/OpenSim.csproj +++ /dev/null @@ -1,186 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {6E597AD4-1F7D-4389-B04C-403EF1046AAB} - Debug - AnyCPU - - - - - OpenSim - JScript - Grid - IE50 - false - Exe - - - OpenSim - - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - - True - 4096 - False - ..\bin\ - False - False - False - 4 - - - - - False - 285212672 - False - - - TRACE - - - False - 4096 - True - ..\bin\ - False - False - False - 4 - - - - - - System.dll - False - - - - System.Xml.dll - False - - - ..\bin\libsecondlife.dll - False - - - ..\bin\Axiom.MathLib.dll - False - - - ..\bin\Db4objects.Db4o.dll - False - - - - - OpenSim.Framework.Console - {1492353A-6133-4557-9AD8-6E24386D70F8} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Physics.Manager - {0FD686EA-1917-469E-A885-1D9DEEA1D340} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Framework - {E267CE4E-F355-4A27-8D0D-CA48FEE7F978} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim.RegionServer/OpenSim.exe.build b/OpenSim.RegionServer/OpenSim.exe.build deleted file mode 100644 index 529f5fb..0000000 --- a/OpenSim.RegionServer/OpenSim.exe.build +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 46b682b..ce49074 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -267,7 +267,7 @@ namespace OpenSim LocalWorld.LoadWorldMap(); m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system"); - LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use + LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); LocalWorld.LoadPrimsFromStorage(); } diff --git a/OpenSim.RegionServer/OpenSimNetworkHandler.cs b/OpenSim.RegionServer/OpenSimNetworkHandler.cs index e3a7375..15ee740 100644 --- a/OpenSim.RegionServer/OpenSimNetworkHandler.cs +++ b/OpenSim.RegionServer/OpenSimNetworkHandler.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; +using libsecondlife; +using OpenSim.Framework.Interfaces; namespace OpenSim { @@ -11,5 +13,6 @@ namespace OpenSim void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); void RemoveClientCircuit(uint circuitcode); void RegisterPacketServer(PacketServer server); + AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); } } diff --git a/OpenSim.RegionServer/SimClient.PacketHandlers.cs b/OpenSim.RegionServer/SimClient.PacketHandlers.cs index 5007a60..f4de974 100644 --- a/OpenSim.RegionServer/SimClient.PacketHandlers.cs +++ b/OpenSim.RegionServer/SimClient.PacketHandlers.cs @@ -57,7 +57,7 @@ namespace OpenSim m_world.RemoveViewerAgent(this); //need to do other cleaning up here too m_clientThreads.Remove(this.CircuitCode); - m_application.RemoveClientCircuit(this.CircuitCode); + m_networkServer.RemoveClientCircuit(this.CircuitCode); this.ClientThread.Abort(); return true; } diff --git a/OpenSim.RegionServer/SimClient.ProcessPackets.cs b/OpenSim.RegionServer/SimClient.ProcessPackets.cs new file mode 100644 index 0000000..56818d2 --- /dev/null +++ b/OpenSim.RegionServer/SimClient.ProcessPackets.cs @@ -0,0 +1,417 @@ +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.world; +using OpenSim.Assets; + +namespace OpenSim +{ + public partial class SimClient + { + protected virtual void ProcessInPacket(Packet Pack) + { + ack_pack(Pack); + if (debug) + { + if (Pack.Type != PacketType.AgentUpdate) + { + Console.WriteLine(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.CompleteAgentMovement: + if (this.m_child) this.UpgradeClient(); + ClientAvatar.CompleteMovement(m_world); + ClientAvatar.SendInitialPosition(); + this.EnableNeighbours(); + break; + case PacketType.RegionHandshakeReply: + m_world.SendLayerData(this); + break; + case PacketType.AgentWearablesRequest: + ClientAvatar.SendInitialAppearance(); + foreach (SimClient client in m_clientThreads.Values) + { + if (client.AgentID != this.AgentID) + { + ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); + this.OutPacket(objupdate); + client.ClientAvatar.SendAppearanceToOtherAgent(this); + } + } + m_world.GetInitialPrims(this); + break; + case PacketType.AgentIsNowWearing: + AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.AgentSetAppearance: + AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; + // Console.WriteLine(appear.ToString()); + this.ClientAvatar.SetAppearance(appear); + break; + case PacketType.ObjectAdd: + m_world.AddNewPrim((ObjectAddPacket)Pack, this); + break; + case PacketType.ObjectLink: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString()); + ObjectLinkPacket link = (ObjectLinkPacket)Pack; + uint parentprimid = 0; + OpenSim.world.Primitive parentprim = null; + if (link.ObjectData.Length > 1) + { + parentprimid = link.ObjectData[0].ObjectLocalID; + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == parentprimid) + { + parentprim = (OpenSim.world.Primitive)ent; + + } + } + for (int i = 1; i < link.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == link.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).MakeParent(parentprim); + } + } + } + } + break; + case PacketType.ObjectScale: + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString()); + break; + case PacketType.ObjectShape: + ObjectShapePacket shape = (ObjectShapePacket)Pack; + for (int i = 0; i < shape.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == shape.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); + } + } + } + break; + 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: + //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); + TransferRequestPacket transfer = (TransferRequestPacket)Pack; + m_assetCache.AddAssetRequest(this, transfer); + break; + case PacketType.AgentUpdate: + ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); + break; + case PacketType.ObjectImage: + ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + for (int i = 0; i < imagePack.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); + } + } + } + break; + case PacketType.ObjectFlagUpdate: + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == flags.AgentData.ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); + } + } + break; + case PacketType.AssetUploadRequest: + AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); + break; + case PacketType.RequestXfer: + //Console.WriteLine(Pack.ToString()); + 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); + //Console.WriteLine(Pack.ToString()); + break; + case PacketType.CreateInventoryItem: + //Console.WriteLine(Pack.ToString()); + CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; + if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) + { + this.UploadAssets.CreateInventoryItem(createItem); + } + else + { + // Console.Write(Pack.ToString()); + this.CreateInventoryItem(createItem); + } + break; + case PacketType.FetchInventory: + //Console.WriteLine("fetch item packet"); + 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; + //Console.WriteLine(Pack.ToString()); + 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) + { + // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); + m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); + } + else + { + asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); + if (asset != null) + { + //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); + m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); + } + else + { + //Console.WriteLine("trying to update inventory item, but asset is null"); + } + } + } + else + { + m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; + } + } + break; + case PacketType.ViewerEffect: + ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; + foreach (SimClient client in m_clientThreads.Values) + { + if (client.AgentID != this.AgentID) + { + viewer.AgentData.AgentID = client.AgentID; + viewer.AgentData.SessionID = client.SessionID; + client.OutPacket(viewer); + } + } + break; + case PacketType.RequestTaskInventory: + // Console.WriteLine(Pack.ToString()); + 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: + // Console.WriteLine(Pack.ToString()); + 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.world.Primitive) + { + this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); + } + } + } + } + } + } + } + } + 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) + { + ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; + ClientAvatar.anim_seq = 1; + ClientAvatar.SendAnimPack(); + } + } + } + break; + case PacketType.ObjectSelect: + ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; + for (int i = 0; i < incomingselect.ObjectData.Length; i++) + { + foreach (Entity ent in m_world.Entities.Values) + { + if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) + { + ((OpenSim.world.Primitive)ent).GetProperites(this); + break; + } + } + } + break; + case PacketType.MapLayerRequest: + this.RequestMapLayer(); + break; + case PacketType.MapBlockRequest: + MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; + this.RequestMapBlock(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); + 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; + } + } + } + } +} diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index f5cfaad..81da10e 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs @@ -80,7 +80,7 @@ namespace OpenSim private AssetCache m_assetCache; private IGridServer m_gridServer; private IUserServer m_userServer = null; - private OpenSimNetworkHandler m_application; + private OpenSimNetworkHandler m_networkServer; private InventoryCache m_inventoryCache; public bool m_sandboxMode; private int cachedtextureserial = 0; @@ -104,12 +104,12 @@ namespace OpenSim m_clientThreads = clientThreads; m_assetCache = assetCache; m_gridServer = gridServer; - m_application = application; + m_networkServer = application; m_inventoryCache = inventoryCache; m_sandboxMode = sandboxMode; m_child = child; m_regionData = regionDat; - + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"OpenSimClient.cs - Started up new client thread to handle incoming request"); cirpack = initialcirpack; userEP = remoteEP; @@ -185,7 +185,7 @@ namespace OpenSim m_world.RemoveViewerAgent(this); m_clientThreads.Remove(this.CircuitCode); - m_application.RemoveClientCircuit(this.CircuitCode); + m_networkServer.RemoveClientCircuit(this.CircuitCode); this.ClientThread.Abort(); } @@ -266,399 +266,6 @@ namespace OpenSim }*/ } - protected virtual void ProcessInPacket(Packet Pack) - { - ack_pack(Pack); - if (debug) - { - if (Pack.Type != PacketType.AgentUpdate) - { - Console.WriteLine(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.CompleteAgentMovement: - if (this.m_child) this.UpgradeClient(); - ClientAvatar.CompleteMovement(m_world); - ClientAvatar.SendInitialPosition(); - this.EnableNeighbours(); - break; - case PacketType.RegionHandshakeReply: - m_world.SendLayerData(this); - break; - case PacketType.AgentWearablesRequest: - ClientAvatar.SendInitialAppearance(); - foreach (SimClient client in m_clientThreads.Values) - { - if (client.AgentID != this.AgentID) - { - ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); - this.OutPacket(objupdate); - client.ClientAvatar.SendAppearanceToOtherAgent(this); - } - } - m_world.GetInitialPrims(this); - break; - case PacketType.AgentIsNowWearing: - AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; - //Console.WriteLine(Pack.ToString()); - break; - case PacketType.AgentSetAppearance: - AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; - // Console.WriteLine(appear.ToString()); - this.ClientAvatar.SetAppearance(appear); - break; - case PacketType.ObjectAdd: - m_world.AddNewPrim((ObjectAddPacket)Pack, this); - break; - case PacketType.ObjectLink: - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,Pack.ToString()); - ObjectLinkPacket link = (ObjectLinkPacket)Pack; - uint parentprimid = 0; - OpenSim.world.Primitive parentprim = null; - if (link.ObjectData.Length > 1) - { - parentprimid = link.ObjectData[0].ObjectLocalID; - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == parentprimid) - { - parentprim = (OpenSim.world.Primitive)ent; - - } - } - for (int i = 1; i < link.ObjectData.Length; i++) - { - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == link.ObjectData[i].ObjectLocalID) - { - ((OpenSim.world.Primitive)ent).MakeParent(parentprim); - } - } - } - } - break; - case PacketType.ObjectScale: - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,Pack.ToString()); - break; - case PacketType.ObjectShape: - ObjectShapePacket shape = (ObjectShapePacket)Pack; - for (int i = 0; i < shape.ObjectData.Length; i++) - { - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == shape.ObjectData[i].ObjectLocalID) - { - ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); - } - } - } - break; - 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: - //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); - TransferRequestPacket transfer = (TransferRequestPacket)Pack; - m_assetCache.AddAssetRequest(this, transfer); - break; - case PacketType.AgentUpdate: - ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); - break; - case PacketType.ObjectImage: - ObjectImagePacket imagePack = (ObjectImagePacket)Pack; - for (int i = 0; i < imagePack.ObjectData.Length; i++) - { - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) - { - ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); - } - } - } - break; - case PacketType.ObjectFlagUpdate: - ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == flags.AgentData.ObjectLocalID) - { - ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); - } - } - break; - case PacketType.AssetUploadRequest: - AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; - this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); - break; - case PacketType.RequestXfer: - //Console.WriteLine(Pack.ToString()); - 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); - //Console.WriteLine(Pack.ToString()); - break; - case PacketType.CreateInventoryItem: - //Console.WriteLine(Pack.ToString()); - CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; - if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) - { - this.UploadAssets.CreateInventoryItem(createItem); - } - else - { - // Console.Write(Pack.ToString()); - this.CreateInventoryItem(createItem); - } - break; - case PacketType.FetchInventory: - //Console.WriteLine("fetch item packet"); - 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; - //Console.WriteLine(Pack.ToString()); - 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) - { - // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); - m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); - } - else - { - asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); - if (asset != null) - { - //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); - m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); - } - else - { - //Console.WriteLine("trying to update inventory item, but asset is null"); - } - } - } - else - { - m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; - } - } - break; - case PacketType.ViewerEffect: - ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; - foreach (SimClient client in m_clientThreads.Values) - { - if (client.AgentID != this.AgentID) - { - viewer.AgentData.AgentID = client.AgentID; - viewer.AgentData.SessionID = client.SessionID; - client.OutPacket(viewer); - } - } - break; - case PacketType.RequestTaskInventory: - // Console.WriteLine(Pack.ToString()); - 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: - // Console.WriteLine(Pack.ToString()); - 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.world.Primitive) - { - this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); - } - } - } - } - } - } - } - } - 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) - { - ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; - ClientAvatar.anim_seq = 1; - ClientAvatar.SendAnimPack(); - } - } - } - break; - case PacketType.ObjectSelect: - ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; - for (int i = 0; i < incomingselect.ObjectData.Length; i++) - { - foreach (Entity ent in m_world.Entities.Values) - { - if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) - { - ((OpenSim.world.Primitive)ent).GetProperites(this); - break; - } - } - } - break; - case PacketType.MapLayerRequest: - this.RequestMapLayer(); - break; - case PacketType.MapBlockRequest: - MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; - this.RequestMapBlock( MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); - 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; - } - } - } - private void ResendUnacked() { int now = Environment.TickCount; @@ -801,11 +408,11 @@ namespace OpenSim if (Pack.Header.Zerocoded) { int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_application.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); + m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); } else { - m_application.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); + m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); } } catch (Exception) @@ -900,7 +507,8 @@ namespace OpenSim protected virtual void AuthUser() { - AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + // 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 @@ -925,36 +533,41 @@ namespace OpenSim // Create Inventory, currently only works for sandbox mode if (m_sandboxMode) { - AgentInventory inventory = null; - if (sessionInfo.LoginInfo.InventoryFolder != null) + this.SetupInventory(sessionInfo); + } + + ClientLoop(); + } + } + + #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)) { - inventory = this.CreateInventory(sessionInfo.LoginInfo.InventoryFolder); - if (sessionInfo.LoginInfo.BaseFolder != null) + 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 (!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) + if (inventorySet[i] != null) { - for (int i = 0; i < inventorySet.Length; i++) - { - if (inventorySet[i] != null) - { - m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); - } - } + m_inventoryCache.AddNewInventoryItem(this, sessionInfo.LoginInfo.BaseFolder, inventorySet[i]); } } } } - - ClientLoop(); } } - private AgentInventory CreateInventory(LLUUID baseFolder) { AgentInventory inventory = null; @@ -1015,6 +628,7 @@ namespace OpenSim m_assetCache.AddAsset(asset); m_inventoryCache.AddNewInventoryItem(this, packet.InventoryBlock.FolderID, asset); } + #endregion public class QueItem { diff --git a/OpenSim.RegionServer/UDPServer.cs b/OpenSim.RegionServer/UDPServer.cs index 89c4f67..12f35ab 100644 --- a/OpenSim.RegionServer/UDPServer.cs +++ b/OpenSim.RegionServer/UDPServer.cs @@ -24,6 +24,8 @@ using OpenSim.GenericConfig; namespace OpenSim { + public delegate AuthenticateResponse AuthenticateSessionHandler(LLUUID sessionID, LLUUID agentID, uint circuitCode); + public class UDPServer : OpenSimNetworkHandler { private Dictionary clientCircuits = new Dictionary(); @@ -45,6 +47,7 @@ namespace OpenSim private bool m_sandbox = false; private bool user_accounts = false; private ConsoleBase m_console; + public AuthenticateSessionHandler AuthenticateHandler; public PacketServer PacketServer { @@ -78,6 +81,7 @@ namespace OpenSim this.user_accounts = accounts; this.m_console = console; PacketServer packetServer = new PacketServer(this); + this.AuthenticateHandler = new AuthenticateSessionHandler(this.m_gridServers.GridServer.AuthenticateSession); } protected virtual void OnReceivedData(IAsyncResult result) @@ -178,5 +182,10 @@ namespace OpenSim } } } + + public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) + { + return this.AuthenticateHandler(sessionID, agentID, circuitCode); + } } } \ No newline at end of file -- cgit v1.1