diff options
author | Adam Frisby | 2008-04-29 14:10:26 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-29 14:10:26 +0000 |
commit | de2ff8e626fbda32321ab00c55c85221881e8298 (patch) | |
tree | 0fd61dc5d5f99d8c8c791aae4931c4fb08e12ff7 /ThirdParty/3Di/RegionProxy | |
parent | * Spring cleaning. (diff) | |
download | opensim-SC-de2ff8e626fbda32321ab00c55c85221881e8298.zip opensim-SC-de2ff8e626fbda32321ab00c55c85221881e8298.tar.gz opensim-SC-de2ff8e626fbda32321ab00c55c85221881e8298.tar.bz2 opensim-SC-de2ff8e626fbda32321ab00c55c85221881e8298.tar.xz |
* Little more spring cleaning.
Diffstat (limited to 'ThirdParty/3Di/RegionProxy')
-rw-r--r-- | ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs | 292 |
1 files changed, 166 insertions, 126 deletions
diff --git a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs index 162b34d..6d55094 100644 --- a/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs +++ b/ThirdParty/3Di/RegionProxy/RegionProxyPlugin.cs | |||
@@ -37,8 +37,8 @@ using Nwc.XmlRpc; | |||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
39 | 39 | ||
40 | [assembly:Addin ("RegionProxy", "0.1")] | 40 | [assembly : Addin("RegionProxy", "0.1")] |
41 | [assembly:AddinDependency ("OpenSim", "0.5")] | 41 | [assembly : AddinDependency("OpenSim", "0.5")] |
42 | 42 | ||
43 | namespace OpenSim.ApplicationPlugins.RegionProxy | 43 | namespace OpenSim.ApplicationPlugins.RegionProxy |
44 | { | 44 | { |
@@ -63,17 +63,19 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
63 | [Extension("/OpenSim/Startup")] | 63 | [Extension("/OpenSim/Startup")] |
64 | public class RegionProxyPlugin : IApplicationPlugin | 64 | public class RegionProxyPlugin : IApplicationPlugin |
65 | { | 65 | { |
66 | private ProxyServer proxy; | ||
67 | private BaseHttpServer command_server; | ||
68 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
67 | private BaseHttpServer command_server; | ||
68 | private ProxyServer proxy; | ||
69 | |||
70 | #region IApplicationPlugin Members | ||
69 | 71 | ||
70 | public void Initialise(OpenSimMain openSim) | 72 | public void Initialise(OpenSimMain openSim) |
71 | { | 73 | { |
72 | Console.WriteLine("Starting proxy"); | 74 | Console.WriteLine("Starting proxy"); |
73 | string proxyURL = openSim.ConfigSource.Configs["Network"].GetString("proxy_url", ""); | 75 | string proxyURL = openSim.ConfigSource.Configs["Network"].GetString("proxy_url", ""); |
74 | if(proxyURL.Length==0) return; | 76 | if (proxyURL.Length == 0) return; |
75 | 77 | ||
76 | uint port = (uint) Int32.Parse(proxyURL.Split(new char[] { ':' })[2]); | 78 | uint port = (uint) Int32.Parse(proxyURL.Split(new char[] {':'})[2]); |
77 | command_server = new BaseHttpServer(port); | 79 | command_server = new BaseHttpServer(port); |
78 | command_server.Start(); | 80 | command_server.Start(); |
79 | command_server.AddXmlRPCHandler("AddPort", AddPort); | 81 | command_server.AddXmlRPCHandler("AddPort", AddPort); |
@@ -84,13 +86,15 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
84 | command_server.AddXmlRPCHandler("UnblockClientMessages", UnblockClientMessages); | 86 | command_server.AddXmlRPCHandler("UnblockClientMessages", UnblockClientMessages); |
85 | command_server.AddXmlRPCHandler("Stop", Stop); | 87 | command_server.AddXmlRPCHandler("Stop", Stop); |
86 | 88 | ||
87 | proxy=new ProxyServer(m_log); | 89 | proxy = new ProxyServer(m_log); |
88 | } | 90 | } |
89 | 91 | ||
90 | public void Close() | 92 | public void Close() |
91 | { | 93 | { |
92 | } | 94 | } |
93 | 95 | ||
96 | #endregion | ||
97 | |||
94 | private XmlRpcResponse Stop(XmlRpcRequest request) | 98 | private XmlRpcResponse Stop(XmlRpcRequest request) |
95 | { | 99 | { |
96 | try | 100 | try |
@@ -107,176 +111,118 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
107 | 111 | ||
108 | private XmlRpcResponse AddPort(XmlRpcRequest request) | 112 | private XmlRpcResponse AddPort(XmlRpcRequest request) |
109 | { | 113 | { |
110 | try { | 114 | try |
115 | { | ||
111 | int clientPort = (int) request.Params[0]; | 116 | int clientPort = (int) request.Params[0]; |
112 | int regionPort = (int) request.Params[1]; | 117 | int regionPort = (int) request.Params[1]; |
113 | string regionUrl = (string) request.Params[2]; | 118 | string regionUrl = (string) request.Params[2]; |
114 | proxy.AddPort(clientPort, regionPort, regionUrl); | 119 | proxy.AddPort(clientPort, regionPort, regionUrl); |
115 | } catch(Exception e) { | 120 | } |
116 | m_log.Error("[PROXY]"+e.Message); | 121 | catch (Exception e) |
117 | m_log.Error("[PROXY]"+e.StackTrace); | 122 | { |
123 | m_log.Error("[PROXY]" + e.Message); | ||
124 | m_log.Error("[PROXY]" + e.StackTrace); | ||
118 | } | 125 | } |
119 | return new XmlRpcResponse(); | 126 | return new XmlRpcResponse(); |
120 | } | 127 | } |
121 | 128 | ||
122 | private XmlRpcResponse AddRegion(XmlRpcRequest request) | 129 | private XmlRpcResponse AddRegion(XmlRpcRequest request) |
123 | { | 130 | { |
124 | try { | 131 | try |
132 | { | ||
125 | int currentRegionPort = (int) request.Params[0]; | 133 | int currentRegionPort = (int) request.Params[0]; |
126 | string currentRegionUrl = (string) request.Params[1]; | 134 | string currentRegionUrl = (string) request.Params[1]; |
127 | int newRegionPort = (int) request.Params[2]; | 135 | int newRegionPort = (int) request.Params[2]; |
128 | string newRegionUrl = (string) request.Params[3]; | 136 | string newRegionUrl = (string) request.Params[3]; |
129 | proxy.AddRegion(currentRegionPort, currentRegionUrl, newRegionPort, newRegionUrl); | 137 | proxy.AddRegion(currentRegionPort, currentRegionUrl, newRegionPort, newRegionUrl); |
130 | } catch(Exception e) { | 138 | } |
131 | m_log.Error("[PROXY]"+e.Message); | 139 | catch (Exception e) |
132 | m_log.Error("[PROXY]"+e.StackTrace); | 140 | { |
141 | m_log.Error("[PROXY]" + e.Message); | ||
142 | m_log.Error("[PROXY]" + e.StackTrace); | ||
133 | } | 143 | } |
134 | return new XmlRpcResponse(); | 144 | return new XmlRpcResponse(); |
135 | } | 145 | } |
136 | 146 | ||
137 | private XmlRpcResponse ChangeRegion(XmlRpcRequest request) | 147 | private XmlRpcResponse ChangeRegion(XmlRpcRequest request) |
138 | { | 148 | { |
139 | try { | 149 | try |
150 | { | ||
140 | int currentRegionPort = (int) request.Params[0]; | 151 | int currentRegionPort = (int) request.Params[0]; |
141 | string currentRegionUrl = (string) request.Params[1]; | 152 | string currentRegionUrl = (string) request.Params[1]; |
142 | int newRegionPort = (int) request.Params[2]; | 153 | int newRegionPort = (int) request.Params[2]; |
143 | string newRegionUrl = (string) request.Params[3]; | 154 | string newRegionUrl = (string) request.Params[3]; |
144 | proxy.ChangeRegion(currentRegionPort, currentRegionUrl, newRegionPort, newRegionUrl); | 155 | proxy.ChangeRegion(currentRegionPort, currentRegionUrl, newRegionPort, newRegionUrl); |
145 | } catch(Exception e) { | 156 | } |
146 | m_log.Error("[PROXY]"+e.Message); | 157 | catch (Exception e) |
147 | m_log.Error("[PROXY]"+e.StackTrace); | 158 | { |
159 | m_log.Error("[PROXY]" + e.Message); | ||
160 | m_log.Error("[PROXY]" + e.StackTrace); | ||
148 | } | 161 | } |
149 | return new XmlRpcResponse(); | 162 | return new XmlRpcResponse(); |
150 | } | 163 | } |
151 | 164 | ||
152 | private XmlRpcResponse DeleteRegion(XmlRpcRequest request) | 165 | private XmlRpcResponse DeleteRegion(XmlRpcRequest request) |
153 | { | 166 | { |
154 | try { | 167 | try |
168 | { | ||
155 | int currentRegionPort = (int) request.Params[0]; | 169 | int currentRegionPort = (int) request.Params[0]; |
156 | string currentRegionUrl = (string) request.Params[1]; | 170 | string currentRegionUrl = (string) request.Params[1]; |
157 | proxy.DeleteRegion(currentRegionPort, currentRegionUrl); | 171 | proxy.DeleteRegion(currentRegionPort, currentRegionUrl); |
158 | } catch(Exception e) { | 172 | } |
159 | m_log.Error("[PROXY]"+e.Message); | 173 | catch (Exception e) |
160 | m_log.Error("[PROXY]"+e.StackTrace); | 174 | { |
175 | m_log.Error("[PROXY]" + e.Message); | ||
176 | m_log.Error("[PROXY]" + e.StackTrace); | ||
161 | } | 177 | } |
162 | return new XmlRpcResponse(); | 178 | return new XmlRpcResponse(); |
163 | } | 179 | } |
164 | 180 | ||
165 | private XmlRpcResponse BlockClientMessages(XmlRpcRequest request) | 181 | private XmlRpcResponse BlockClientMessages(XmlRpcRequest request) |
166 | { | 182 | { |
167 | try { | 183 | try |
184 | { | ||
168 | string regionUrl = (string) request.Params[0]; | 185 | string regionUrl = (string) request.Params[0]; |
169 | int regionPort = (int) request.Params[1]; | 186 | int regionPort = (int) request.Params[1]; |
170 | proxy.BlockClientMessages(regionUrl, regionPort); | 187 | proxy.BlockClientMessages(regionUrl, regionPort); |
171 | } catch(Exception e) { | 188 | } |
172 | m_log.Error("[PROXY]"+e.Message); | 189 | catch (Exception e) |
173 | m_log.Error("[PROXY]"+e.StackTrace); | 190 | { |
191 | m_log.Error("[PROXY]" + e.Message); | ||
192 | m_log.Error("[PROXY]" + e.StackTrace); | ||
174 | } | 193 | } |
175 | return new XmlRpcResponse(); | 194 | return new XmlRpcResponse(); |
176 | } | 195 | } |
177 | 196 | ||
178 | private XmlRpcResponse UnblockClientMessages(XmlRpcRequest request) | 197 | private XmlRpcResponse UnblockClientMessages(XmlRpcRequest request) |
179 | { | 198 | { |
180 | try { | 199 | try |
200 | { | ||
181 | string regionUrl = (string) request.Params[0]; | 201 | string regionUrl = (string) request.Params[0]; |
182 | int regionPort = (int) request.Params[1]; | 202 | int regionPort = (int) request.Params[1]; |
183 | proxy.UnblockClientMessages(regionUrl, regionPort); | 203 | proxy.UnblockClientMessages(regionUrl, regionPort); |
184 | } catch(Exception e) { | 204 | } |
185 | m_log.Error("[PROXY]"+e.Message); | 205 | catch (Exception e) |
186 | m_log.Error("[PROXY]"+e.StackTrace); | 206 | { |
207 | m_log.Error("[PROXY]" + e.Message); | ||
208 | m_log.Error("[PROXY]" + e.StackTrace); | ||
187 | } | 209 | } |
188 | return new XmlRpcResponse(); | 210 | return new XmlRpcResponse(); |
189 | } | 211 | } |
190 | } | 212 | } |
191 | 213 | ||
192 | 214 | ||
193 | public class ProxyServer { | 215 | public class ProxyServer |
194 | protected AsyncCallback receivedData; | 216 | { |
195 | protected ProxyMap proxy_map = new ProxyMap(); | ||
196 | protected readonly ILog m_log; | 217 | protected readonly ILog m_log; |
218 | protected ProxyMap proxy_map = new ProxyMap(); | ||
219 | protected AsyncCallback receivedData; | ||
197 | protected bool running; | 220 | protected bool running; |
198 | 221 | ||
199 | protected class ProxyMap | ||
200 | { | ||
201 | public class RegionData | ||
202 | { | ||
203 | public bool isBlocked = false; | ||
204 | public Queue storedMessages = new Queue(); | ||
205 | public List<EndPoint> regions = new List<EndPoint>(); | ||
206 | } | ||
207 | |||
208 | private Dictionary<EndPoint, RegionData> map; | ||
209 | |||
210 | public ProxyMap() { | ||
211 | map = new Dictionary<EndPoint, RegionData>(); | ||
212 | } | ||
213 | |||
214 | public void Add(EndPoint client, EndPoint region) | ||
215 | { | ||
216 | if(map.ContainsKey(client)) | ||
217 | { | ||
218 | map[client].regions.Add(region); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | RegionData regions = new RegionData(); | ||
223 | map.Add(client, regions); | ||
224 | regions.regions.Add(region); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | public RegionData GetRegionData(EndPoint client) | ||
229 | { | ||
230 | return map[client]; | ||
231 | } | ||
232 | |||
233 | public EndPoint GetClient(EndPoint region) | ||
234 | { | ||
235 | foreach (KeyValuePair<EndPoint, RegionData> pair in map) | ||
236 | { | ||
237 | if(pair.Value.regions.Contains(region)) | ||
238 | { | ||
239 | return pair.Key; | ||
240 | } | ||
241 | } | ||
242 | return null; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | protected class ServerData { | ||
247 | public Socket server; | ||
248 | public EndPoint clientEP; | ||
249 | public EndPoint senderEP; | ||
250 | public IPEndPoint serverIP; | ||
251 | public byte[] recvBuffer = new byte[4096]; | ||
252 | |||
253 | public ServerData() | ||
254 | { | ||
255 | server = null; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | protected class StoredMessage | ||
260 | { | ||
261 | public byte[] buffer; | ||
262 | public int length; | ||
263 | public EndPoint senderEP; | ||
264 | public ServerData sd; | ||
265 | |||
266 | public StoredMessage(byte[] buffer, int length, int maxLength, EndPoint senderEP, ServerData sd) | ||
267 | { | ||
268 | this.buffer = new byte[maxLength]; | ||
269 | this.length = length; | ||
270 | for(int i=0; i<length; i++) this.buffer[i]=buffer[i]; | ||
271 | this.senderEP = senderEP; | ||
272 | this.sd = sd; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | public ProxyServer(ILog log) | 222 | public ProxyServer(ILog log) |
277 | { | 223 | { |
278 | m_log = log; | 224 | m_log = log; |
279 | running=false; | 225 | running = false; |
280 | receivedData = new AsyncCallback(OnReceivedData); | 226 | receivedData = new AsyncCallback(OnReceivedData); |
281 | } | 227 | } |
282 | 228 | ||
@@ -293,7 +239,8 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
293 | ProxyMap.RegionData rd = proxy_map.GetRegionData(client); | 239 | ProxyMap.RegionData rd = proxy_map.GetRegionData(client); |
294 | 240 | ||
295 | rd.isBlocked = false; | 241 | rd.isBlocked = false; |
296 | while(rd.storedMessages.Count > 0) { | 242 | while (rd.storedMessages.Count > 0) |
243 | { | ||
297 | StoredMessage msg = (StoredMessage) rd.storedMessages.Dequeue(); | 244 | StoredMessage msg = (StoredMessage) rd.storedMessages.Dequeue(); |
298 | //m_log.Verbose("[PROXY]"+"Resending blocked message from {0}", msg.senderEP); | 245 | //m_log.Verbose("[PROXY]"+"Resending blocked message from {0}", msg.senderEP); |
299 | SendMessage(msg.buffer, msg.length, msg.senderEP, msg.sd); | 246 | SendMessage(msg.buffer, msg.length, msg.senderEP, msg.sd); |
@@ -316,10 +263,10 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
316 | data.regions.Clear(); | 263 | data.regions.Clear(); |
317 | data.regions.Add(new IPEndPoint(IPAddress.Parse(newRegionUrl), newRegionPort)); | 264 | data.regions.Add(new IPEndPoint(IPAddress.Parse(newRegionUrl), newRegionPort)); |
318 | } | 265 | } |
319 | 266 | ||
320 | public void DeleteRegion(int oldRegionPort, string oldRegionUrl) | 267 | public void DeleteRegion(int oldRegionPort, string oldRegionUrl) |
321 | { | 268 | { |
322 | m_log.InfoFormat("[PROXY]"+"DeleteRegion {0} {1}", oldRegionPort, oldRegionUrl); | 269 | m_log.InfoFormat("[PROXY]" + "DeleteRegion {0} {1}", oldRegionPort, oldRegionUrl); |
323 | EndPoint regionEP = new IPEndPoint(IPAddress.Parse(oldRegionUrl), oldRegionPort); | 270 | EndPoint regionEP = new IPEndPoint(IPAddress.Parse(oldRegionUrl), oldRegionPort); |
324 | EndPoint client = proxy_map.GetClient(regionEP); | 271 | EndPoint client = proxy_map.GetClient(regionEP); |
325 | ProxyMap.RegionData data = proxy_map.GetRegionData(client); | 272 | ProxyMap.RegionData data = proxy_map.GetRegionData(client); |
@@ -348,9 +295,8 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
348 | 295 | ||
349 | try | 296 | try |
350 | { | 297 | { |
351 | |||
352 | m_log.InfoFormat("[PROXY] Opening UDP socket on {0}", sd.clientEP); | 298 | m_log.InfoFormat("[PROXY] Opening UDP socket on {0}", sd.clientEP); |
353 | sd.serverIP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), ((IPEndPoint)sd.clientEP).Port); | 299 | sd.serverIP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), ((IPEndPoint) sd.clientEP).Port); |
354 | sd.server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | 300 | sd.server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); |
355 | sd.server.Bind(sd.serverIP); | 301 | sd.server.Bind(sd.serverIP); |
356 | 302 | ||
@@ -385,15 +331,14 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
385 | { | 331 | { |
386 | running = false; | 332 | running = false; |
387 | m_log.InfoFormat("[PROXY] Stopping the proxy server"); | 333 | m_log.InfoFormat("[PROXY] Stopping the proxy server"); |
388 | |||
389 | } | 334 | } |
390 | 335 | ||
391 | 336 | ||
392 | protected virtual void OnReceivedData(IAsyncResult result) | 337 | protected virtual void OnReceivedData(IAsyncResult result) |
393 | { | 338 | { |
394 | if(!running) return; | 339 | if (!running) return; |
395 | 340 | ||
396 | ServerData sd = (ServerData)result.AsyncState; | 341 | ServerData sd = (ServerData) result.AsyncState; |
397 | sd.senderEP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 342 | sd.senderEP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); |
398 | 343 | ||
399 | try | 344 | try |
@@ -431,7 +376,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
431 | m_log.ErrorFormat("[PROXY] BeginReceiveFrom failed, retrying... {0}", sd.clientEP); | 376 | m_log.ErrorFormat("[PROXY] BeginReceiveFrom failed, retrying... {0}", sd.clientEP); |
432 | m_log.Error("[PROXY]" + e.Message); | 377 | m_log.Error("[PROXY]" + e.Message); |
433 | m_log.Error("[PROXY]" + e.StackTrace); | 378 | m_log.Error("[PROXY]" + e.StackTrace); |
434 | OpenPort(sd); | 379 | OpenPort(sd); |
435 | } | 380 | } |
436 | } | 381 | } |
437 | } | 382 | } |
@@ -471,7 +416,6 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
471 | m_log.Error("[PROXY]" + e.StackTrace); | 416 | m_log.Error("[PROXY]" + e.StackTrace); |
472 | return; | 417 | return; |
473 | } | 418 | } |
474 | |||
475 | } | 419 | } |
476 | else | 420 | else |
477 | { | 421 | { |
@@ -480,7 +424,8 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
480 | ProxyMap.RegionData rd = proxy_map.GetRegionData(sd.clientEP); | 424 | ProxyMap.RegionData rd = proxy_map.GetRegionData(sd.clientEP); |
481 | foreach (EndPoint region in rd.regions) | 425 | foreach (EndPoint region in rd.regions) |
482 | { | 426 | { |
483 | if(rd.isBlocked) { | 427 | if (rd.isBlocked) |
428 | { | ||
484 | rd.storedMessages.Enqueue(new StoredMessage(buffer, length, numBytes, senderEP, sd)); | 429 | rd.storedMessages.Enqueue(new StoredMessage(buffer, length, numBytes, senderEP, sd)); |
485 | } | 430 | } |
486 | else | 431 | else |
@@ -502,5 +447,100 @@ namespace OpenSim.ApplicationPlugins.RegionProxy | |||
502 | } | 447 | } |
503 | } | 448 | } |
504 | } | 449 | } |
450 | |||
451 | #region Nested type: ProxyMap | ||
452 | |||
453 | protected class ProxyMap | ||
454 | { | ||
455 | private Dictionary<EndPoint, RegionData> map; | ||
456 | |||
457 | public ProxyMap() | ||
458 | { | ||
459 | map = new Dictionary<EndPoint, RegionData>(); | ||
460 | } | ||
461 | |||
462 | public void Add(EndPoint client, EndPoint region) | ||
463 | { | ||
464 | if (map.ContainsKey(client)) | ||
465 | { | ||
466 | map[client].regions.Add(region); | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | RegionData regions = new RegionData(); | ||
471 | map.Add(client, regions); | ||
472 | regions.regions.Add(region); | ||
473 | } | ||
474 | } | ||
475 | |||
476 | public RegionData GetRegionData(EndPoint client) | ||
477 | { | ||
478 | return map[client]; | ||
479 | } | ||
480 | |||
481 | public EndPoint GetClient(EndPoint region) | ||
482 | { | ||
483 | foreach (KeyValuePair<EndPoint, RegionData> pair in map) | ||
484 | { | ||
485 | if (pair.Value.regions.Contains(region)) | ||
486 | { | ||
487 | return pair.Key; | ||
488 | } | ||
489 | } | ||
490 | return null; | ||
491 | } | ||
492 | |||
493 | #region Nested type: RegionData | ||
494 | |||
495 | public class RegionData | ||
496 | { | ||
497 | public bool isBlocked = false; | ||
498 | public List<EndPoint> regions = new List<EndPoint>(); | ||
499 | public Queue storedMessages = new Queue(); | ||
500 | } | ||
501 | |||
502 | #endregion | ||
503 | } | ||
504 | |||
505 | #endregion | ||
506 | |||
507 | #region Nested type: ServerData | ||
508 | |||
509 | protected class ServerData | ||
510 | { | ||
511 | public EndPoint clientEP; | ||
512 | public byte[] recvBuffer = new byte[4096]; | ||
513 | public EndPoint senderEP; | ||
514 | public Socket server; | ||
515 | public IPEndPoint serverIP; | ||
516 | |||
517 | public ServerData() | ||
518 | { | ||
519 | server = null; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | #endregion | ||
524 | |||
525 | #region Nested type: StoredMessage | ||
526 | |||
527 | protected class StoredMessage | ||
528 | { | ||
529 | public byte[] buffer; | ||
530 | public int length; | ||
531 | public ServerData sd; | ||
532 | public EndPoint senderEP; | ||
533 | |||
534 | public StoredMessage(byte[] buffer, int length, int maxLength, EndPoint senderEP, ServerData sd) | ||
535 | { | ||
536 | this.buffer = new byte[maxLength]; | ||
537 | this.length = length; | ||
538 | for (int i = 0; i < length; i++) this.buffer[i] = buffer[i]; | ||
539 | this.senderEP = senderEP; | ||
540 | this.sd = sd; | ||
541 | } | ||
542 | } | ||
543 | |||
544 | #endregion | ||
505 | } | 545 | } |
506 | } | 546 | } \ No newline at end of file |