diff options
Diffstat (limited to 'OpenSim/Framework/RegionLoader')
-rw-r--r-- | OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index de4898a..f0ffc2c 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | |||
@@ -48,6 +48,9 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
48 | 48 | ||
49 | public RegionInfo[] LoadRegions() | 49 | public RegionInfo[] LoadRegions() |
50 | { | 50 | { |
51 | int tries = 3; | ||
52 | int wait = 2000; | ||
53 | |||
51 | if (m_configSource == null) | 54 | if (m_configSource == null) |
52 | { | 55 | { |
53 | m_log.Error("[WEBLOADER]: Unable to load configuration source!"); | 56 | m_log.Error("[WEBLOADER]: Unable to load configuration source!"); |
@@ -64,35 +67,47 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
64 | } | 67 | } |
65 | else | 68 | else |
66 | { | 69 | { |
67 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); | 70 | while (tries > 0) |
68 | webRequest.Timeout = 30000; //30 Second Timeout | ||
69 | m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); | ||
70 | HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); | ||
71 | m_log.Debug("[WEBLOADER]: Downloading region information..."); | ||
72 | StreamReader reader = new StreamReader(webResponse.GetResponseStream()); | ||
73 | string xmlSource = String.Empty; | ||
74 | string tempStr = reader.ReadLine(); | ||
75 | while (tempStr != null) | ||
76 | { | ||
77 | xmlSource = xmlSource + tempStr; | ||
78 | tempStr = reader.ReadLine(); | ||
79 | } | ||
80 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | ||
81 | xmlSource.Length); | ||
82 | XmlDocument xmlDoc = new XmlDocument(); | ||
83 | xmlDoc.LoadXml(xmlSource); | ||
84 | if (xmlDoc.FirstChild.Name == "Regions") | ||
85 | { | 71 | { |
86 | RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; | 72 | HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); |
87 | int i; | 73 | webRequest.Timeout = 30000; //30 Second Timeout |
88 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) | 74 | m_log.Debug("[WEBLOADER]: Sending Download Request..."); |
75 | HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); | ||
76 | m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server..."); | ||
77 | StreamReader reader = new StreamReader(webResponse.GetResponseStream()); | ||
78 | string xmlSource = String.Empty; | ||
79 | string tempStr = reader.ReadLine(); | ||
80 | while (tempStr != null) | ||
81 | { | ||
82 | xmlSource = xmlSource + tempStr; | ||
83 | tempStr = reader.ReadLine(); | ||
84 | } | ||
85 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | ||
86 | xmlSource.Length); | ||
87 | XmlDocument xmlDoc = new XmlDocument(); | ||
88 | xmlDoc.LoadXml(xmlSource); | ||
89 | if (xmlDoc.FirstChild.Name == "Regions") | ||
89 | { | 90 | { |
90 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); | 91 | RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; |
91 | regionInfos[i] = | 92 | int i; |
92 | new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); | 93 | for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) |
94 | { | ||
95 | m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); | ||
96 | regionInfos[i] = | ||
97 | new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource); | ||
98 | } | ||
99 | |||
100 | if (i > 0) | ||
101 | return regionInfos; | ||
93 | } | 102 | } |
94 | 103 | ||
95 | return regionInfos; | 104 | m_log.Debug("[WEBLOADER]: Request yielded no regions."); |
105 | tries--; | ||
106 | if (tries > 0) | ||
107 | { | ||
108 | m_log.Debug("[WEBLOADER]: Retrying"); | ||
109 | System.Threading.Thread.Sleep(wait); | ||
110 | } | ||
96 | } | 111 | } |
97 | return null; | 112 | return null; |
98 | } | 113 | } |