diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Examples/SimpleApp2/Program.cs | 160 |
1 files changed, 160 insertions, 0 deletions
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim; | ||
5 | using OpenSim.Servers; | ||
6 | using OpenSim.GridInterfaces.Local; | ||
7 | using OpenSim.Framework.Interfaces; | ||
8 | using OpenSim.Framework.Types; | ||
9 | using OpenSim.UserServer; | ||
10 | using OpenSim.Framework.Console; | ||
11 | using OpenSim.world; | ||
12 | using OpenSim.Physics.Manager; | ||
13 | using OpenSim.Assets; | ||
14 | using libsecondlife; | ||
15 | |||
16 | namespace SimpleApp2 | ||
17 | { | ||
18 | class Program : IWorld, IAssetReceiver, conscmd_callback | ||
19 | { | ||
20 | private ConsoleBase m_console; | ||
21 | private RegionInfo m_regionInfo; | ||
22 | private float[] m_map; | ||
23 | |||
24 | private void Run() | ||
25 | { | ||
26 | m_console = new ConsoleBase(null, "SimpleApp", this, false); | ||
27 | MainConsole.Instance = m_console; | ||
28 | |||
29 | m_map = CreateMap(); | ||
30 | |||
31 | CheckSumServer checksumServer = new CheckSumServer(12036); | ||
32 | checksumServer.ServerListener(); | ||
33 | |||
34 | string simAddr = "127.0.0.1"; | ||
35 | int simPort = 9000; | ||
36 | |||
37 | LoginServer loginServer = new LoginServer(simAddr, simPort, 0, 0, false); | ||
38 | loginServer.Startup(); | ||
39 | |||
40 | AuthenticateSessionsLocal localSessions = new AuthenticateSessionsLocal(); | ||
41 | loginServer.SetSessionHandler(localSessions.AddNewSessionHandler); | ||
42 | |||
43 | InventoryCache inventoryCache = new InventoryCache(); | ||
44 | |||
45 | LocalAssetServer assetServer = new LocalAssetServer(); | ||
46 | assetServer.SetServerInfo("http://127.0.0.1:8003/", ""); | ||
47 | assetServer.SetReceiver(this); | ||
48 | |||
49 | AssetCache assetCache = new AssetCache(assetServer); | ||
50 | |||
51 | UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_console, localSessions); | ||
52 | PacketServer packetServer = new MyPacketServer(m_map, udpServer, (uint) simPort ); | ||
53 | udpServer.ServerListener(); | ||
54 | |||
55 | ClientView.TerrainManager = new TerrainManager(new SecondLife()); | ||
56 | |||
57 | m_regionInfo = new RegionInfo(); | ||
58 | |||
59 | udpServer.LocalWorld = this; | ||
60 | |||
61 | // World world = new World(udpServer.PacketServer.ClientAPIs, regionInfo); | ||
62 | // PhysicsScene physicsScene = new NullPhysicsScene(); | ||
63 | // world.PhysicsScene = physicsScene; | ||
64 | // udpServer.LocalWorld = world; | ||
65 | |||
66 | BaseHttpServer httpServer = new BaseHttpServer(simPort); | ||
67 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); | ||
68 | httpServer.Start(); | ||
69 | |||
70 | m_console.WriteLine(LogPriority.NORMAL, "Press enter to quit."); | ||
71 | m_console.ReadLine(); | ||
72 | } | ||
73 | |||
74 | private float[] CreateMap() | ||
75 | { | ||
76 | float[] map = new float[65536]; | ||
77 | |||
78 | for (int i = 0; i < 65536; i++) | ||
79 | { | ||
80 | int x = i % 256; | ||
81 | int y = i / 256; | ||
82 | |||
83 | map[i] = (float)(x + y / 2); | ||
84 | } | ||
85 | |||
86 | return map; | ||
87 | } | ||
88 | |||
89 | private void AddNewSessionHandler(Login loginData) | ||
90 | { | ||
91 | m_console.WriteLine(LogPriority.NORMAL, "Recieved Login from [{0}] [{1}]", loginData.First, loginData.Last); | ||
92 | } | ||
93 | |||
94 | static void Main(string[] args) | ||
95 | { | ||
96 | Program app = new Program(); | ||
97 | |||
98 | app.Run(); | ||
99 | } | ||
100 | |||
101 | #region IWorld Members | ||
102 | |||
103 | void IWorld.AddNewAvatar(IClientAPI remoteClient, LLUUID agentID, bool child) | ||
104 | { | ||
105 | remoteClient.SendRegionHandshake(m_regionInfo); | ||
106 | } | ||
107 | |||
108 | void IWorld.RemoveAvatar(LLUUID agentID) | ||
109 | { | ||
110 | throw new Exception("The method or operation is not implemented."); | ||
111 | } | ||
112 | |||
113 | RegionInfo IWorld.RegionInfo | ||
114 | { | ||
115 | get { return m_regionInfo; } | ||
116 | } | ||
117 | |||
118 | object IWorld.SyncRoot | ||
119 | { | ||
120 | get { return this; } | ||
121 | } | ||
122 | |||
123 | private uint m_nextLocalId = 1; | ||
124 | |||
125 | uint IWorld.NextLocalId | ||
126 | { | ||
127 | get { return m_nextLocalId++; } | ||
128 | } | ||
129 | |||
130 | #endregion | ||
131 | |||
132 | #region IAssetReceiver Members | ||
133 | |||
134 | public void AssetReceived(AssetBase asset, bool IsTexture) | ||
135 | { | ||
136 | throw new Exception("The method or operation is not implemented."); | ||
137 | } | ||
138 | |||
139 | public void AssetNotFound(AssetBase asset) | ||
140 | { | ||
141 | throw new Exception("The method or operation is not implemented."); | ||
142 | } | ||
143 | |||
144 | #endregion | ||
145 | |||
146 | #region conscmd_callback Members | ||
147 | |||
148 | public void RunCmd(string cmd, string[] cmdparams) | ||
149 | { | ||
150 | throw new Exception("The method or operation is not implemented."); | ||
151 | } | ||
152 | |||
153 | public void Show(string ShowWhat) | ||
154 | { | ||
155 | throw new Exception("The method or operation is not implemented."); | ||
156 | } | ||
157 | |||
158 | #endregion | ||
159 | } | ||
160 | } | ||