diff options
author | lbsa71 | 2007-07-03 07:06:08 +0000 |
---|---|---|
committer | lbsa71 | 2007-07-03 07:06:08 +0000 |
commit | 73a5ec391aa5600cb779044fbf335ce0537e9500 (patch) | |
tree | 9df98727f377806ab6e5afdabc3299cfa03a178b /OpenSim/Region/Examples | |
parent | You can now substitute %name% in the filename argument for terrain save & loa... (diff) | |
download | opensim-SC_OLD-73a5ec391aa5600cb779044fbf335ce0537e9500.zip opensim-SC_OLD-73a5ec391aa5600cb779044fbf335ce0537e9500.tar.gz opensim-SC_OLD-73a5ec391aa5600cb779044fbf335ce0537e9500.tar.bz2 opensim-SC_OLD-73a5ec391aa5600cb779044fbf335ce0537e9500.tar.xz |
* Completed conceptual LlsdMethod - everything resides in SimpleApp pending guru approval.
Diffstat (limited to 'OpenSim/Region/Examples')
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs | 44 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 25 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/Program.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj | 3 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build | 1 |
5 files changed, 70 insertions, 23 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs new file mode 100644 index 0000000..c3d3d33 --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs | |||
@@ -0,0 +1,44 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework.Servers; | ||
5 | using OpenSim.Region.Capabilities; | ||
6 | using libsecondlife; | ||
7 | using System.Collections; | ||
8 | |||
9 | namespace OpenSim.Framework.Servers | ||
10 | { | ||
11 | public class LlsdMethodEntry<TResponse, TRequest> : ILlsdMethodHandler | ||
12 | where TRequest : new() | ||
13 | { | ||
14 | private LlsdMethod<TResponse, TRequest> m_method; | ||
15 | |||
16 | |||
17 | public LlsdMethodEntry( ) | ||
18 | { | ||
19 | |||
20 | } | ||
21 | |||
22 | public LlsdMethodEntry(LlsdMethod<TResponse, TRequest> method) | ||
23 | { | ||
24 | m_method = method; | ||
25 | } | ||
26 | |||
27 | #region ILlsdMethodHandler Members | ||
28 | |||
29 | public string Handle(string body, string path) | ||
30 | { | ||
31 | Encoding _enc = System.Text.Encoding.UTF8; | ||
32 | Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes( body )); | ||
33 | TRequest request = new TRequest(); | ||
34 | |||
35 | LLSDHelpers.DeserialiseLLSDMap(hash, request ); | ||
36 | |||
37 | TResponse response = m_method(request); | ||
38 | |||
39 | return LLSDHelpers.SerialiseLLSDReply( response ); | ||
40 | } | ||
41 | |||
42 | #endregion | ||
43 | } | ||
44 | } | ||
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 3ba9c77..8e6fd8f 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -17,13 +17,11 @@ namespace SimpleApp | |||
17 | { | 17 | { |
18 | public class MyWorld : Scene | 18 | public class MyWorld : Scene |
19 | { | 19 | { |
20 | private RegionInfo m_regionInfo; | ||
21 | private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars; | 20 | private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars; |
22 | 21 | ||
23 | public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) | 22 | public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) |
24 | : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) | 23 | : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) |
25 | { | 24 | { |
26 | m_regionInfo = regionInfo; | ||
27 | m_avatars = new List<Avatar>(); | 25 | m_avatars = new List<Avatar>(); |
28 | } | 26 | } |
29 | 27 | ||
@@ -68,12 +66,12 @@ namespace SimpleApp | |||
68 | 66 | ||
69 | client.OnCompleteMovementToRegion += delegate() | 67 | client.OnCompleteMovementToRegion += delegate() |
70 | { | 68 | { |
71 | client.MoveAgentIntoRegion(m_regionInfo, pos, LLVector3.Zero ); | 69 | client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero ); |
72 | }; | 70 | }; |
73 | 71 | ||
74 | client.OnCompleteMovementToRegion += delegate() | 72 | client.OnCompleteMovementToRegion += delegate() |
75 | { | 73 | { |
76 | client.SendAvatarData(m_regionInfo.RegionHandle, client.FirstName, | 74 | client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName, |
77 | client.LastName, client.AgentId, 0, | 75 | client.LastName, client.AgentId, 0, |
78 | pos, null); | 76 | pos, null); |
79 | 77 | ||
@@ -83,7 +81,7 @@ namespace SimpleApp | |||
83 | 81 | ||
84 | }; | 82 | }; |
85 | 83 | ||
86 | client.SendRegionHandshake(m_regionInfo); | 84 | client.SendRegionHandshake(m_regInfo); |
87 | 85 | ||
88 | CreateAndAddScenePresence(client); | 86 | CreateAndAddScenePresence(client); |
89 | 87 | ||
@@ -94,23 +92,6 @@ namespace SimpleApp | |||
94 | client.SendWearables( AvatarWearable.DefaultWearables ); | 92 | client.SendWearables( AvatarWearable.DefaultWearables ); |
95 | } | 93 | } |
96 | 94 | ||
97 | public RegionInfo RegionInfo | ||
98 | { | ||
99 | get { return m_regionInfo; } | ||
100 | } | ||
101 | |||
102 | public object SyncRoot | ||
103 | { | ||
104 | get { return this; } | ||
105 | } | ||
106 | |||
107 | private uint m_nextLocalId = 1; | ||
108 | |||
109 | public uint NextLocalId | ||
110 | { | ||
111 | get { return m_nextLocalId++; } | ||
112 | } | ||
113 | |||
114 | #endregion | 95 | #endregion |
115 | } | 96 | } |
116 | } | 97 | } |
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 2c5fb4d..6bf6657 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs | |||
@@ -64,7 +64,9 @@ namespace SimpleApp | |||
64 | udpServer.LocalWorld = world; | 64 | udpServer.LocalWorld = world; |
65 | 65 | ||
66 | httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); | 66 | httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); |
67 | httpServer.AddLlsdMethod<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo); | 67 | |
68 | RegisterLlsdHandler<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo); | ||
69 | |||
68 | httpServer.Start(); | 70 | httpServer.Start(); |
69 | 71 | ||
70 | m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); | 72 | m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); |
@@ -81,7 +83,23 @@ namespace SimpleApp | |||
81 | { | 83 | { |
82 | return new LLSDMapLayerResponse(); | 84 | return new LLSDMapLayerResponse(); |
83 | } | 85 | } |
86 | |||
87 | ILlsdMethodHandler m_handler; | ||
84 | 88 | ||
89 | private void RegisterLlsdHandler<TResponse, TRequest>( string path, LlsdMethod<TResponse, TRequest> method ) | ||
90 | where TRequest : new() | ||
91 | { | ||
92 | // path should be handler key, but for now just conceptually store it. | ||
93 | m_handler = new LlsdMethodEntry<TResponse, TRequest>( method ); | ||
94 | } | ||
95 | |||
96 | private string ProcessLlsdMethod( string request,string path ) | ||
97 | { | ||
98 | LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest> concreteHandler = new LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest>( LlsdMethodDemo ); | ||
99 | |||
100 | return m_handler.Handle(request, path); | ||
101 | } | ||
102 | |||
85 | private bool AddNewSessionHandler(ulong regionHandle, Login loginData) | 103 | private bool AddNewSessionHandler(ulong regionHandle, Login loginData) |
86 | { | 104 | { |
87 | m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); | 105 | m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); |
diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj index 3ed0efc..1e726b2 100644 --- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj +++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj | |||
@@ -154,6 +154,9 @@ | |||
154 | </ProjectReference> | 154 | </ProjectReference> |
155 | </ItemGroup> | 155 | </ItemGroup> |
156 | <ItemGroup> | 156 | <ItemGroup> |
157 | <Compile Include="LlsdMethodEntry.cs"> | ||
158 | <SubType>Code</SubType> | ||
159 | </Compile> | ||
157 | <Compile Include="MyWorld.cs"> | 160 | <Compile Include="MyWorld.cs"> |
158 | <SubType>Code</SubType> | 161 | <SubType>Code</SubType> |
159 | </Compile> | 162 | </Compile> |
diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build index 0c6234a..a826a37 100644 --- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build +++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build | |||
@@ -11,6 +11,7 @@ | |||
11 | <resources prefix="SimpleApp" dynamicprefix="true" > | 11 | <resources prefix="SimpleApp" dynamicprefix="true" > |
12 | </resources> | 12 | </resources> |
13 | <sources failonempty="true"> | 13 | <sources failonempty="true"> |
14 | <include name="LlsdMethodEntry.cs" /> | ||
14 | <include name="MyWorld.cs" /> | 15 | <include name="MyWorld.cs" /> |
15 | <include name="Program.cs" /> | 16 | <include name="Program.cs" /> |
16 | <include name="Properties/AssemblyInfo.cs" /> | 17 | <include name="Properties/AssemblyInfo.cs" /> |