mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
* 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)
This commit is contained in:
69
OpenSim/Examples/SimpleApp2/MyClientView.cs
Normal file
69
OpenSim/Examples/SimpleApp2/MyClientView.cs
Normal file
@@ -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<uint, IClientAPI> m_clientAPIs;
|
||||
|
||||
public MyClientView(float[] map, Dictionary<uint, IClientAPI> clientAPIs, EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
OpenSim/Examples/SimpleApp2/MyPacketServer.cs
Normal file
30
OpenSim/Examples/SimpleApp2/MyPacketServer.cs
Normal file
@@ -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<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
|
||||
{
|
||||
// (EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
160
OpenSim/Examples/SimpleApp2/Program.cs
Normal file
160
OpenSim/Examples/SimpleApp2/Program.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
33
OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs
Normal file
33
OpenSim/Examples/SimpleApp2/Properties/AssemblyInfo.cs
Normal file
@@ -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")]
|
||||
87
OpenSim/Examples/SimpleApp2/SimpleApp2.csproj
Normal file
87
OpenSim/Examples/SimpleApp2/SimpleApp2.csproj
Normal file
@@ -0,0 +1,87 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C84B2171-D386-4377-B490-9C5A56674B9E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SimpleApp2</RootNamespace>
|
||||
<AssemblyName>SimpleApp2</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MyClientView.cs" />
|
||||
<Compile Include="MyPacketServer.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
|
||||
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.Framework.Console</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
|
||||
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.Framework</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj">
|
||||
<Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.Servers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Common\XmlRpcCS\XMLRPC.csproj">
|
||||
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
|
||||
<Name>XMLRPC</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OpenSim.GridInterfaces\Local\OpenSim.GridInterfaces.Local.csproj">
|
||||
<Project>{546099CD-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.GridInterfaces.Local</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
|
||||
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.Physics.Manager</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OpenSim.RegionServer\OpenSim.RegionServer.csproj">
|
||||
<Project>{632E1BFD-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.RegionServer</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OpenSim.World\OpenSim.World.csproj">
|
||||
<Project>{642A14A8-0000-0000-0000-000000000000}</Project>
|
||||
<Name>OpenSim.World</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user