From 4224b695acc2e1ad0199dc0ad7f560494182ed54 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sat, 9 Jun 2007 21:45:58 +0000 Subject: * LogFile now defaults to "{apptype}.log" * cleaned away suo and user files. * added handy string chat variety to the API * Moved LockPhysicsEngine on World to SyncRoot on IWorld * Introduced NextLocalId instead of World fuggliness. * Transformed GetRegionInfo to Property on IWorld for great justice * Extracted default wearables (good to have) * Deleted unused BaseServer * Used IWorld instead of World wherever possible * The client constructor's not getting unused port any longer. * Extracted ClientView factoring so PacketServer can be tweaked. * Added SendLayerData to World * Made WorldBase abstract and cleaned it up a bit * added OpenGrid.Framework.Communications.dll.build and OpenSim.World.dll.build to svn * Added code for two examples (but not in prebuild yet) --- OpenSim/Examples/SimpleApp/MyWorld.cs | 101 +++++++++++++ OpenSim/Examples/SimpleApp/Program.cs | 110 ++++++++++++++ .../Examples/SimpleApp/Properties/AssemblyInfo.cs | 33 +++++ OpenSim/Examples/SimpleApp/SimpleApp.csproj | 86 +++++++++++ OpenSim/Examples/SimpleApp2/MyClientView.cs | 69 +++++++++ OpenSim/Examples/SimpleApp2/MyPacketServer.cs | 30 ++++ OpenSim/Examples/SimpleApp2/Program.cs | 160 +++++++++++++++++++++ .../Examples/SimpleApp2/Properties/AssemblyInfo.cs | 33 +++++ OpenSim/Examples/SimpleApp2/SimpleApp2.csproj | 87 +++++++++++ 9 files changed, 709 insertions(+) create mode 100644 OpenSim/Examples/SimpleApp/MyWorld.cs create mode 100644 OpenSim/Examples/SimpleApp/Program.cs create mode 100644 OpenSim/Examples/SimpleApp/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Examples/SimpleApp/SimpleApp.csproj create mode 100644 OpenSim/Examples/SimpleApp2/MyClientView.cs create mode 100644 OpenSim/Examples/SimpleApp2/MyPacketServer.cs create mode 100644 OpenSim/Examples/SimpleApp2/Program.cs create mode 100644 OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Examples/SimpleApp2/SimpleApp2.csproj (limited to 'OpenSim/Examples') diff --git a/OpenSim/Examples/SimpleApp/MyWorld.cs b/OpenSim/Examples/SimpleApp/MyWorld.cs new file mode 100644 index 0000000..27775f1 --- /dev/null +++ b/OpenSim/Examples/SimpleApp/MyWorld.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Console; +using libsecondlife; + +namespace SimpleApp +{ + public class MyWorld : IWorld + { + private RegionInfo m_regionInfo; + + public MyWorld(RegionInfo regionInfo) + { + m_regionInfo = regionInfo; + } + + private void SendLayerData(IClientAPI remoteClient) + { + float[] map = new float[65536]; + + for (int i = 0; i < 65536; i++) + { + int x = i % 256; + int y = i / 256; + + map[i] = (float)(x + y / 2); + } + + remoteClient.SendLayerData(map); + } + + #region IWorld Members + + void IWorld.AddNewAvatar(IClientAPI client, LLUUID agentID, bool child) + { + LLVector3 pos = new LLVector3(128, 128, 128); + + client.OnRegionHandShakeReply += SendLayerData; + client.OnChatFromViewer += + delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + { + // Echo it (so you know what you typed) + client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); + client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero ); + }; + + client.OnRequestWearables += SendWearables; + + client.OnCompleteMovementToRegion += delegate() + { + client.MoveAgentIntoRegion(m_regionInfo); + }; + + client.OnCompleteMovementToRegion += delegate() + { + client.SendAvatarData(m_regionInfo, client.FirstName, + client.LastName, client.AgentId, 0, + pos); + + client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero ); + }; + + client.SendRegionHandshake(m_regionInfo); + + } + + private void SendWearables( IClientAPI client ) + { + client.SendWearables( AvatarWearable.DefaultWearables ); + } + + void IWorld.RemoveAvatar(LLUUID agentID) + { + + } + + RegionInfo IWorld.RegionInfo + { + get { return m_regionInfo; } + } + + object IWorld.SyncRoot + { + get { return this; } + } + + private uint m_nextLocalId = 1; + + uint IWorld.NextLocalId + { + get { return m_nextLocalId++; } + } + + #endregion + + + } +} diff --git a/OpenSim/Examples/SimpleApp/Program.cs b/OpenSim/Examples/SimpleApp/Program.cs new file mode 100644 index 0000000..e44bdba --- /dev/null +++ b/OpenSim/Examples/SimpleApp/Program.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim; +using OpenSim.Servers; +using OpenSim.GridInterfaces.Local; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.UserServer; +using OpenSim.Framework.Console; +using OpenSim.world; +using OpenSim.Physics.Manager; +using OpenSim.Assets; +using libsecondlife; + +namespace SimpleApp +{ + class Program : IAssetReceiver, conscmd_callback + { + private ConsoleBase m_console; + + private void Run() + { + m_console = new ConsoleBase(null, "SimpleApp", this, false); + MainConsole.Instance = m_console; + + CheckSumServer checksumServer = new CheckSumServer(12036); + checksumServer.ServerListener(); + + string simAddr = "127.0.0.1"; + int simPort = 9000; + + LoginServer loginServer = new LoginServer( simAddr, simPort, 0, 0, false ); + loginServer.Startup(); + + AuthenticateSessionsLocal localSessions = new AuthenticateSessionsLocal(); + loginServer.SetSessionHandler(localSessions.AddNewSessionHandler ); + + InventoryCache inventoryCache = new InventoryCache(); + + LocalAssetServer assetServer = new LocalAssetServer(); + assetServer.SetServerInfo("http://127.0.0.1:8003/", ""); + assetServer.SetReceiver(this); + + AssetCache assetCache = new AssetCache(assetServer); + + UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_console, localSessions ); + PacketServer packetServer = new PacketServer( udpServer, (uint) simPort ); + udpServer.ServerListener(); + + ClientView.TerrainManager = new TerrainManager(new SecondLife()); + + RegionInfo regionInfo = new RegionInfo(); + + udpServer.LocalWorld = new MyWorld( regionInfo ); + + // World world = new World(udpServer.PacketServer.ClientAPIs, regionInfo); + // PhysicsScene physicsScene = new NullPhysicsScene(); + // world.PhysicsScene = physicsScene; + // udpServer.LocalWorld = world; + + BaseHttpServer httpServer = new BaseHttpServer( simPort ); + httpServer.AddXmlRPCHandler( "login_to_simulator", loginServer.XmlRpcLoginMethod ); + httpServer.Start(); + + m_console.WriteLine( LogPriority.NORMAL, "Press enter to quit."); + m_console.ReadLine(); + } + + private void AddNewSessionHandler(Login loginData) + { + m_console.WriteLine( LogPriority.NORMAL, "Recieved Login from [{0}] [{1}]", loginData.First, loginData.Last ); + } + + #region IAssetReceiver Members + + public void AssetReceived( AssetBase asset, bool IsTexture) + { + throw new Exception("The method or operation is not implemented."); + } + + public void AssetNotFound( AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + + #region conscmd_callback Members + + public void RunCmd(string cmd, string[] cmdparams) + { + throw new Exception("The method or operation is not implemented."); + } + + public void Show(string ShowWhat) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + + static void Main(string[] args) + { + Program app = new Program(); + + app.Run(); + } + } +} diff --git a/OpenSim/Examples/SimpleApp/Properties/AssemblyInfo.cs b/OpenSim/Examples/SimpleApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0f9bf0f --- /dev/null +++ b/OpenSim/Examples/SimpleApp/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SimpleApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Playahead AB")] +[assembly: AssemblyProduct("SimpleApp")] +[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Examples/SimpleApp/SimpleApp.csproj b/OpenSim/Examples/SimpleApp/SimpleApp.csproj new file mode 100644 index 0000000..51e14de --- /dev/null +++ b/OpenSim/Examples/SimpleApp/SimpleApp.csproj @@ -0,0 +1,86 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AD062D99-DD53-4D37-A4B8-2AF635377AEB} + Exe + Properties + SimpleApp + SimpleApp + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\bin\libsecondlife.dll + + + + + + + + + + + + + {A7CD0630-0000-0000-0000-000000000000} + OpenSim.Framework.Console + + + {8ACA2445-0000-0000-0000-000000000000} + OpenSim.Framework + + + {8BB20F0A-0000-0000-0000-000000000000} + OpenSim.Servers + + + {8E81D43C-0000-0000-0000-000000000000} + XMLRPC + + + {546099CD-0000-0000-0000-000000000000} + OpenSim.GridInterfaces.Local + + + {8BE16150-0000-0000-0000-000000000000} + OpenSim.Physics.Manager + + + {632E1BFD-0000-0000-0000-000000000000} + OpenSim.RegionServer + + + {642A14A8-0000-0000-0000-000000000000} + OpenSim.World + + + + + \ No newline at end of file diff --git a/OpenSim/Examples/SimpleApp2/MyClientView.cs b/OpenSim/Examples/SimpleApp2/MyClientView.cs new file mode 100644 index 0000000..dd8869c --- /dev/null +++ b/OpenSim/Examples/SimpleApp2/MyClientView.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using System.Net; +using libsecondlife.Packets; +using OpenSim.Assets; +using OpenSim.Framework.Types; +using OpenSim.Framework; + +namespace SimpleApp2 +{ + public class MyClientView : ClientView + { + private float[] m_map; + private Dictionary m_clientAPIs; + + public MyClientView(float[] map, Dictionary clientAPIs, EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) + : base(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions) + { + m_map = map; + m_clientAPIs = clientAPIs; + + OnRegionHandShakeReply += RegionHandShakeReplyHandler; + OnChatFromViewer += ChatHandler; + OnRequestWearables += RequestWearablesHandler; + OnCompleteMovementToRegion += CompleteMovementToRegionHandler; + } + + private void ChatHandler(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + { + // Echo it (so you know what you typed) + SendChatMessage(message, type, fromPos, fromName, fromAgentID); + SendChatMessage("Ready.", 1, fromPos, "System", LLUUID.Zero); + } + + private void CompleteMovementToRegionHandler() + { + LLVector3 pos = new LLVector3(128, 128, 128); + + MoveAgentIntoRegion(m_world.RegionInfo); + + SendAvatarData( m_world.RegionInfo, FirstName, + LastName, AgentId, 0, + pos); + + SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero); + + + + // OpenSim.world.Primitive prim = new OpenSim.world.Primitive( m_clientAPIs, m_world.RegionInfo.RegionHandle, m_world, AgentId ); + + // SendNewPrim( prim ); + + } + + private void RegionHandShakeReplyHandler(IClientAPI client) + { + client.SendLayerData(m_map); + } + + private void RequestWearablesHandler(IClientAPI client) + { + SendWearables(AvatarWearable.DefaultWearables); + } + } +} diff --git a/OpenSim/Examples/SimpleApp2/MyPacketServer.cs b/OpenSim/Examples/SimpleApp2/MyPacketServer.cs new file mode 100644 index 0000000..9c21016 --- /dev/null +++ b/OpenSim/Examples/SimpleApp2/MyPacketServer.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim; +using OpenSim.Assets; +using System.Net; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework; + +namespace SimpleApp2 +{ + public class MyPacketServer : PacketServer + { + private float[] m_map; + + public MyPacketServer(float[] map, OpenSimNetworkHandler networkHandler, uint port ) : base( networkHandler, port ) + { + m_map = map; + } + + protected override ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) + { + // (EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) + + + return new MyClientView(m_map, ClientAPIs, remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions); + } + } +} diff --git a/OpenSim/Examples/SimpleApp2/Program.cs b/OpenSim/Examples/SimpleApp2/Program.cs new file mode 100644 index 0000000..9b977f6 --- /dev/null +++ b/OpenSim/Examples/SimpleApp2/Program.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim; +using OpenSim.Servers; +using OpenSim.GridInterfaces.Local; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.UserServer; +using OpenSim.Framework.Console; +using OpenSim.world; +using OpenSim.Physics.Manager; +using OpenSim.Assets; +using libsecondlife; + +namespace SimpleApp2 +{ + class Program : IWorld, IAssetReceiver, conscmd_callback + { + private ConsoleBase m_console; + private RegionInfo m_regionInfo; + private float[] m_map; + + private void Run() + { + m_console = new ConsoleBase(null, "SimpleApp", this, false); + MainConsole.Instance = m_console; + + m_map = CreateMap(); + + CheckSumServer checksumServer = new CheckSumServer(12036); + checksumServer.ServerListener(); + + string simAddr = "127.0.0.1"; + int simPort = 9000; + + LoginServer loginServer = new LoginServer(simAddr, simPort, 0, 0, false); + loginServer.Startup(); + + AuthenticateSessionsLocal localSessions = new AuthenticateSessionsLocal(); + loginServer.SetSessionHandler(localSessions.AddNewSessionHandler); + + InventoryCache inventoryCache = new InventoryCache(); + + LocalAssetServer assetServer = new LocalAssetServer(); + assetServer.SetServerInfo("http://127.0.0.1:8003/", ""); + assetServer.SetReceiver(this); + + AssetCache assetCache = new AssetCache(assetServer); + + UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_console, localSessions); + PacketServer packetServer = new MyPacketServer(m_map, udpServer, (uint) simPort ); + udpServer.ServerListener(); + + ClientView.TerrainManager = new TerrainManager(new SecondLife()); + + m_regionInfo = new RegionInfo(); + + udpServer.LocalWorld = this; + + // World world = new World(udpServer.PacketServer.ClientAPIs, regionInfo); + // PhysicsScene physicsScene = new NullPhysicsScene(); + // world.PhysicsScene = physicsScene; + // udpServer.LocalWorld = world; + + BaseHttpServer httpServer = new BaseHttpServer(simPort); + httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); + httpServer.Start(); + + m_console.WriteLine(LogPriority.NORMAL, "Press enter to quit."); + m_console.ReadLine(); + } + + private float[] CreateMap() + { + float[] map = new float[65536]; + + for (int i = 0; i < 65536; i++) + { + int x = i % 256; + int y = i / 256; + + map[i] = (float)(x + y / 2); + } + + return map; + } + + private void AddNewSessionHandler(Login loginData) + { + m_console.WriteLine(LogPriority.NORMAL, "Recieved Login from [{0}] [{1}]", loginData.First, loginData.Last); + } + + static void Main(string[] args) + { + Program app = new Program(); + + app.Run(); + } + + #region IWorld Members + + void IWorld.AddNewAvatar(IClientAPI remoteClient, LLUUID agentID, bool child) + { + remoteClient.SendRegionHandshake(m_regionInfo); + } + + void IWorld.RemoveAvatar(LLUUID agentID) + { + throw new Exception("The method or operation is not implemented."); + } + + RegionInfo IWorld.RegionInfo + { + get { return m_regionInfo; } + } + + object IWorld.SyncRoot + { + get { return this; } + } + + private uint m_nextLocalId = 1; + + uint IWorld.NextLocalId + { + get { return m_nextLocalId++; } + } + + #endregion + + #region IAssetReceiver Members + + public void AssetReceived(AssetBase asset, bool IsTexture) + { + throw new Exception("The method or operation is not implemented."); + } + + public void AssetNotFound(AssetBase asset) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + + #region conscmd_callback Members + + public void RunCmd(string cmd, string[] cmdparams) + { + throw new Exception("The method or operation is not implemented."); + } + + public void Show(string ShowWhat) + { + throw new Exception("The method or operation is not implemented."); + } + + #endregion + } +} diff --git a/OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs b/OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f7d6aae --- /dev/null +++ b/OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SimpleApp2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Playahead AB")] +[assembly: AssemblyProduct("SimpleApp2")] +[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bdda0707-02b4-46ca-87ce-ab3c12558a4a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Examples/SimpleApp2/SimpleApp2.csproj b/OpenSim/Examples/SimpleApp2/SimpleApp2.csproj new file mode 100644 index 0000000..92664e3 --- /dev/null +++ b/OpenSim/Examples/SimpleApp2/SimpleApp2.csproj @@ -0,0 +1,87 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {C84B2171-D386-4377-B490-9C5A56674B9E} + Exe + Properties + SimpleApp2 + SimpleApp2 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\bin\libsecondlife.dll + + + + + + + + + + + + + + {A7CD0630-0000-0000-0000-000000000000} + OpenSim.Framework.Console + + + {8ACA2445-0000-0000-0000-000000000000} + OpenSim.Framework + + + {8BB20F0A-0000-0000-0000-000000000000} + OpenSim.Servers + + + {8E81D43C-0000-0000-0000-000000000000} + XMLRPC + + + {546099CD-0000-0000-0000-000000000000} + OpenSim.GridInterfaces.Local + + + {8BE16150-0000-0000-0000-000000000000} + OpenSim.Physics.Manager + + + {632E1BFD-0000-0000-0000-000000000000} + OpenSim.RegionServer + + + {642A14A8-0000-0000-0000-000000000000} + OpenSim.World + + + + + \ No newline at end of file -- cgit v1.1