29 using System.Collections.Generic;
31 using System.Reflection;
35 using log4net.Appender;
38 using OpenSim.Framework;
39 using OpenSim.Services.Interfaces;
41 using OpenSim.Services.Connectors;
51 public static void Main(
string[] args)
53 ConsoleAppender consoleAppender =
new ConsoleAppender();
54 consoleAppender.Layout =
55 new PatternLayout(
"%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
56 log4net.Config.BasicConfigurator.Configure(consoleAppender);
58 string serverURI =
"http://127.0.0.1:8001";
61 GridRegion r1 = CreateRegion(
"Test Region 1", 1000, 1000);
62 GridRegion r2 = CreateRegion(
"Test Region 2", 1001, 1000);
63 GridRegion r3 = CreateRegion(
"Test Region 3", 1005, 1000);
65 Console.WriteLine(
"[GRID CLIENT]: *** Registering region 1");
66 string msg = m_Connector.RegisterRegion(UUID.Zero, r1);
67 if (msg == String.Empty)
68 Console.WriteLine(
"[GRID CLIENT]: Successfully registered region 1");
70 Console.WriteLine(
"[GRID CLIENT]: region 1 failed to register");
72 Console.WriteLine(
"[GRID CLIENT]: *** Registering region 2");
73 msg = m_Connector.RegisterRegion(UUID.Zero, r2);
74 if (msg == String.Empty)
75 Console.WriteLine(
"[GRID CLIENT]: Successfully registered region 2");
77 Console.WriteLine(
"[GRID CLIENT]: region 2 failed to register");
79 Console.WriteLine(
"[GRID CLIENT]: *** Registering region 3");
80 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
81 if (msg == String.Empty)
82 Console.WriteLine(
"[GRID CLIENT]: Successfully registered region 3");
84 Console.WriteLine(
"[GRID CLIENT]: region 3 failed to register");
88 Console.WriteLine(
"[GRID CLIENT]: *** Deregistering region 3");
89 success = m_Connector.DeregisterRegion(r3.RegionID);
91 Console.WriteLine(
"[GRID CLIENT]: Successfully deregistered region 3");
93 Console.WriteLine(
"[GRID CLIENT]: region 3 failed to deregister");
94 Console.WriteLine(
"[GRID CLIENT]: *** Registering region 3 again");
95 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
96 if (msg == String.Empty)
97 Console.WriteLine(
"[GRID CLIENT]: Successfully registered region 3");
99 Console.WriteLine(
"[GRID CLIENT]: region 3 failed to register");
101 Console.WriteLine(
"[GRID CLIENT]: *** GetNeighbours of region 1");
102 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
104 Console.WriteLine(
"[GRID CLIENT]: GetNeighbours of region 1 failed");
105 else if (regions.Count > 0)
107 if (regions.Count != 1)
108 Console.WriteLine(
"[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
110 Console.WriteLine(
"[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
113 Console.WriteLine(
"[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
116 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
117 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
119 Console.WriteLine(
"[GRID CLIENT]: GetRegionByUUID returned null");
121 Console.WriteLine(
"[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
123 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
124 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
126 Console.WriteLine(
"[GRID CLIENT]: GetRegionByUUID returned null");
128 Console.WriteLine(
"[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
130 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
131 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
133 Console.WriteLine(
"[GRID CLIENT]: GetRegionByName returned null");
135 Console.WriteLine(
"[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
137 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
138 region = m_Connector.GetRegionByName(UUID.Zero,
"Foo");
140 Console.WriteLine(
"[GRID CLIENT]: GetRegionByName returned null");
142 Console.WriteLine(
"[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
144 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
145 regions = m_Connector.GetRegionsByName(UUID.Zero,
"Test", 10);
147 Console.WriteLine(
"[GRID CLIENT]: GetRegionsByName returned null");
149 Console.WriteLine(
"[GRID CLIENT]: GetRegionsByName returned " + regions.Count +
" regions");
151 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
152 regions = m_Connector.GetRegionRange(UUID.Zero,
153 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002),
154 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) );
156 Console.WriteLine(
"[GRID CLIENT]: GetRegionRange returned null");
158 Console.WriteLine(
"[GRID CLIENT]: GetRegionRange returned " + regions.Count +
" regions");
159 Console.WriteLine(
"[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
160 regions = m_Connector.GetRegionRange(UUID.Zero,
161 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950),
162 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) );
164 Console.WriteLine(
"[GRID CLIENT]: GetRegionRange returned null");
166 Console.WriteLine(
"[GRID CLIENT]: GetRegionRange returned " + regions.Count +
" regions");
168 Console.Write(
"Proceed to deregister? Press enter...");
172 Console.WriteLine(
"[GRID CLIENT]: *** Deregistering region 1");
173 success = m_Connector.DeregisterRegion(r1.RegionID);
175 Console.WriteLine(
"[GRID CLIENT]: Successfully deregistered region 1");
177 Console.WriteLine(
"[GRID CLIENT]: region 1 failed to deregister");
178 Console.WriteLine(
"[GRID CLIENT]: *** Deregistering region 2");
179 success = m_Connector.DeregisterRegion(r2.RegionID);
181 Console.WriteLine(
"[GRID CLIENT]: Successfully deregistered region 2");
183 Console.WriteLine(
"[GRID CLIENT]: region 2 failed to deregister");
184 Console.WriteLine(
"[GRID CLIENT]: *** Deregistering region 3");
185 success = m_Connector.DeregisterRegion(r3.RegionID);
187 Console.WriteLine(
"[GRID CLIENT]: Successfully deregistered region 3");
189 Console.WriteLine(
"[GRID CLIENT]: region 3 failed to deregister");
193 private static GridRegion CreateRegion(
string name, uint xcell, uint ycell)
196 region.RegionName = name;
197 region.RegionID = UUID.Random();
198 region.ExternalHostName =
"127.0.0.1";
199 region.HttpPort = 9000;
200 region.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 9000);
static void Main(string[] args)
Interactive OpenSim region server
OpenSim.Services.Interfaces.GridRegion GridRegion