* Minor fixes and cleanups around code being used for Rex Module work.

0.6.0-stable
Adam Frisby 2008-09-14 01:49:47 +00:00
parent f2d60976d0
commit e946b40fdd
3 changed files with 17 additions and 27 deletions

View File

@ -29,14 +29,13 @@ using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
namespace OpenSim.Region.ClientStack namespace OpenSim.Region.ClientStack
{ {
public interface IClientNetworkServer public interface IClientNetworkServer
{ {
void Initialise(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass); void Initialise(IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass);
Socket Server { get; } Socket Server { get; }
bool HandlesRegion(Location x); bool HandlesRegion(Location x);

View File

@ -35,7 +35,6 @@ using OpenMetaverse.Packets;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.ClientStack.LindenUDP namespace OpenSim.Region.ClientStack.LindenUDP
@ -141,15 +140,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// </summary> /// </summary>
/// <param name="_listenIP"></param> /// <param name="_listenIP"></param>
/// <param name="port"></param> /// <param name="port"></param>
/// <param name="proxyPortOffset"></param> /// <param name="proxyPortOffsetParm"></param>
/// <param name="allow_alternate_port"></param> /// <param name="allow_alternate_port"></param>
/// <param name="assetCache"></param> /// <param name="assetCache"></param>
/// <param name="circuitManager"></param> /// <param name="circuitManager"></param>
public void Initialise( public void Initialise(
IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager circuitManager) IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager circuitManager)
{ {
this.proxyPortOffset = proxyPortOffset; proxyPortOffset = proxyPortOffsetParm;
listenPort = (uint) (port + proxyPortOffset); listenPort = (uint) (port + proxyPortOffsetParm);
listenIP = _listenIP; listenIP = _listenIP;
Allow_Alternate_Port = allow_alternate_port; Allow_Alternate_Port = allow_alternate_port;
m_assetCache = assetCache; m_assetCache = assetCache;
@ -159,7 +158,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Return new port // Return new port
// This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered.
// So the option allow_alternate_ports="true" was added to default.xml // So the option allow_alternate_ports="true" was added to default.xml
port = (uint)(listenPort - proxyPortOffset); port = (uint)(listenPort - proxyPortOffsetParm);
} }
protected virtual void CreatePacketServer() protected virtual void CreatePacketServer()
@ -175,7 +174,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected virtual void OnReceivedData(IAsyncResult result) protected virtual void OnReceivedData(IAsyncResult result)
{ {
ipeSender = new IPEndPoint(listenIP, 0); ipeSender = new IPEndPoint(listenIP, 0);
epSender = (EndPoint) ipeSender; epSender = ipeSender;
Packet packet = null; Packet packet = null;
int numBytes = 1; int numBytes = 1;
@ -218,7 +217,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// //
int z; int z;
for (z = numBytes ; z < RecvBuffer.Length ; z++) for (z = numBytes ; z < RecvBuffer.Length ; z++)
RecvBuffer[z] = (byte)0; RecvBuffer[z] = 0;
epProxy = epSender; epProxy = epSender;
if (proxyPortOffset != 0) if (proxyPortOffset != 0)
@ -242,7 +241,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Debug("[CLIENT]: " + e.ToString()); m_log.Debug("[CLIENT]: " + e);
} }
} }
@ -255,7 +254,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// do we already have a circuit for this endpoint // do we already have a circuit for this endpoint
uint circuit; uint circuit;
bool ret = false; bool ret;
lock (clientCircuits) lock (clientCircuits)
{ {
ret = clientCircuits.TryGetValue(epSender, out circuit); ret = clientCircuits.TryGetValue(epSender, out circuit);
@ -312,7 +311,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
catch (Exception a) catch (Exception a)
{ {
m_log.Info("[UDPSERVER]: " + a.ToString()); m_log.Info("[UDPSERVER]: " + a);
} }
try try
@ -413,8 +412,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen");
ipeSender = new IPEndPoint(listenIP, 0); ipeSender = new IPEndPoint(listenIP, 0);
epSender = (EndPoint)ipeSender; epSender = ipeSender;
ReceivedData = new AsyncCallback(OnReceivedData); ReceivedData = OnReceivedData;
m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
m_log.Info("[UDPSERVER]: Listening on port " + newPort); m_log.Info("[UDPSERVER]: Listening on port " + newPort);
@ -429,7 +428,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//EndPoint packetSender) //EndPoint packetSender)
{ {
// find the endpoint for this circuit // find the endpoint for this circuit
EndPoint sendto = null; EndPoint sendto;
try { try {
sendto = (EndPoint)clientCircuits_reverse[circuitcode]; sendto = (EndPoint)clientCircuits_reverse[circuitcode];
} catch { } catch {
@ -457,7 +456,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public virtual void RemoveClientCircuit(uint circuitcode) public virtual void RemoveClientCircuit(uint circuitcode)
{ {
EndPoint sendto = null; EndPoint sendto;
if (clientCircuits_reverse.Contains(circuitcode)) if (clientCircuits_reverse.Contains(circuitcode))
{ {
sendto = (EndPoint)clientCircuits_reverse[circuitcode]; sendto = (EndPoint)clientCircuits_reverse[circuitcode];
@ -497,14 +496,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!clientCircuits.ContainsKey(userEP)) if (!clientCircuits.ContainsKey(userEP))
clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); clientCircuits.Add(userEP, useCircuit.CircuitCode.Code);
else else
m_log.Error("[CLIENT]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); m_log.Error("[CLIENT]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code + ". NOT adding.");
} }
// This data structure is synchronized, so we don't need the lock // This data structure is synchronized, so we don't need the lock
if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP);
else else
m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding.");
lock (proxyCircuits) lock (proxyCircuits)
{ {

View File

@ -26,15 +26,12 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Security; using System.Net.Security;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Net.Sockets;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using OpenMetaverse; using OpenMetaverse;
@ -42,12 +39,7 @@ using OpenMetaverse.StructuredData;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Capabilities;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;