aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-23 17:16:13 +0000
committerJustin Clarke Casey2008-10-23 17:16:13 +0000
commitee3c428040fd026a92f3dd9a43ab4f88dec38181 (patch)
tree1e165d077d9fe2ba88a9b064c79faa827baf19f7 /OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
parentadding documentation for region_master_uuid to XML doc comments (diff)
downloadopensim-SC_OLD-ee3c428040fd026a92f3dd9a43ab4f88dec38181.zip
opensim-SC_OLD-ee3c428040fd026a92f3dd9a43ab4f88dec38181.tar.gz
opensim-SC_OLD-ee3c428040fd026a92f3dd9a43ab4f88dec38181.tar.bz2
opensim-SC_OLD-ee3c428040fd026a92f3dd9a43ab4f88dec38181.tar.xz
* Refactor LLUDPServer slightly so that unit tests can pass in data synchronously. Shouldn't be any functional change
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs81
1 files changed, 49 insertions, 32 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index e3ded7f..22086f8 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -180,39 +180,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
180 { 180 {
181 Packet packet = null; 181 Packet packet = null;
182 int numBytes = 1; 182 int numBytes = 1;
183 bool ok = false;
184 EndPoint epSender = new IPEndPoint(IPAddress.Any, 0); 183 EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
185 184
186 try 185 if (EndReceive(out numBytes, result, ref epSender))
187 {
188 numBytes = m_socket.EndReceiveFrom(result, ref epSender);
189 ok = true;
190 }
191 catch (SocketException e)
192 {
193 // TODO : Actually only handle those states that we have control over, re-throw everything else,
194 // TODO: implement cases as we encounter them.
195 //m_log.Error("[[CLIENT]: ]: Connection Error! - " + e.ToString());
196 switch (e.SocketErrorCode)
197 {
198 case SocketError.AlreadyInProgress:
199 return;
200
201 case SocketError.NetworkReset:
202 case SocketError.ConnectionReset:
203 break;
204
205 default:
206 throw;
207 }
208 }
209 catch (ObjectDisposedException e)
210 {
211 m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName);
212 // Uhh, what object, and why? this needs better handling.
213 }
214
215 if (ok)
216 { 186 {
217 // Make sure we are getting zeroes when running off the 187 // Make sure we are getting zeroes when running off the
218 // end of grab / degrab packets from old clients 188 // end of grab / degrab packets from old clients
@@ -297,7 +267,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
297 } 267 }
298 } 268 }
299 269
300 private void BeginReceive() 270 /// <summary>
271 /// Begin an asynchronous receive of the next bit of raw data
272 /// </summary>
273 protected virtual void BeginReceive()
301 { 274 {
302 try 275 try
303 { 276 {
@@ -315,6 +288,50 @@ namespace OpenSim.Region.ClientStack.LindenUDP
315 ResetEndPoint(); 288 ResetEndPoint();
316 } 289 }
317 } 290 }
291
292 /// <summary>
293 /// Finish the process of asynchronously receiving the next bit of raw data
294 /// </summary>
295 /// <param name="numBytes">The number of bytes received. Will return 0 if no bytes were recieved
296 /// <param name="result"></param>
297 /// <param name="epSender">The sender of the data</param>
298 /// <returns></returns>
299 protected virtual bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender)
300 {
301 bool hasReceivedOkay = false;
302 numBytes = 0;
303
304 try
305 {
306 numBytes = m_socket.EndReceiveFrom(result, ref epSender);
307 hasReceivedOkay = true;
308 }
309 catch (SocketException e)
310 {
311 // TODO : Actually only handle those states that we have control over, re-throw everything else,
312 // TODO: implement cases as we encounter them.
313 //m_log.Error("[[CLIENT]: ]: Connection Error! - " + e.ToString());
314 switch (e.SocketErrorCode)
315 {
316 case SocketError.AlreadyInProgress:
317 return hasReceivedOkay;
318
319 case SocketError.NetworkReset:
320 case SocketError.ConnectionReset:
321 break;
322
323 default:
324 throw;
325 }
326 }
327 catch (ObjectDisposedException e)
328 {
329 m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName);
330 // Uhh, what object, and why? this needs better handling.
331 }
332
333 return hasReceivedOkay;
334 }
318 335
319 private void ResetEndPoint() 336 private void ResetEndPoint()
320 { 337 {