* More refactorings of UDPServer.

* Removed all references where possible.
* Renamed lots of variables from UDPServerXYZ to clientServerXYZ
0.6.0-stable
Adam Frisby 2008-05-02 18:26:19 +00:00
parent a1c0e89067
commit 67bbfadc06
9 changed files with 32 additions and 148 deletions

View File

@ -24,103 +24,3 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace OpenSim.Framework.Servers
{
/*
public class CheckSumServer : UDPServerBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public CheckSumServer(int port)
: base(port)
{
}
protected override void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
{
SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
checkreply.DataBlock.Checksum = 3220703154;//180572585;
checkreply.DataBlock.Flags = 0;
checkreply.DataBlock.MajorVersion = 1;
checkreply.DataBlock.MinorVersion = 15;
checkreply.DataBlock.PatchVersion = 0;
checkreply.DataBlock.ServerVersion = 0;
checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
this.SendPacket(checkreply, epSender);
/*
//if we wanted to echo the the checksum/ version from the client (so that any client worked)
SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
this.SendPacket(checkrequest, epSender);
}
else if (packet.Type == PacketType.TemplateChecksumReply)
{
//echo back the client checksum reply (Hegemon's method)
TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
this.SendPacket(checkreply2, epSender);
}
else
{
}
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
private void SendPacket(Packet Pack, EndPoint endp)
{
if (!Pack.Header.Resent)
{
Pack.Header.Sequence = 1;
}
byte[] ZeroOutBuffer = new byte[4096];
byte[] sendbuffer;
sendbuffer = Pack.ToBytes();
try
{
if (Pack.Header.Zerocoded)
{
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
}
else
{
this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
}
}
catch (Exception)
{
m_log.Warn("CheckSumServer.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
}
}
private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
{
this.Server.SendTo(buffer, size, flags, endp);
}
* }
*/
}

View File

@ -40,7 +40,6 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Region.ClientStack;
using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Region.Communications.Local;
using OpenSim.Region.Communications.OGS1;
using OpenSim.Region.Environment;
@ -106,7 +105,7 @@ namespace OpenSim
get { return m_httpServer; }
}
public List<IClientNetworkServer> UdpServers
public List<IClientNetworkServer> ClientServers
{
get { return m_clientServers; }
}
@ -409,12 +408,6 @@ namespace OpenSim
plugin.Initialise(this);
m_plugins.Add(plugin);
}
// Start UDP servers
//for (int i = 0; i < m_udpServers.Count; i++)
//{
// m_udpServers[i].ServerListener();
// }
}
protected override void Initialize()
@ -496,8 +489,8 @@ namespace OpenSim
Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
}
IClientNetworkServer udpServer;
Scene scene = SetupScene(regionInfo, proxyOffset, out udpServer, m_permissions);
IClientNetworkServer clientServer;
Scene scene = SetupScene(regionInfo, proxyOffset, out clientServer, m_permissions);
m_log.Info("[MODULES]: Loading Region's modules");
@ -549,9 +542,9 @@ namespace OpenSim
m_sceneManager.Add(scene);
m_clientServers.Add(udpServer);
m_clientServers.Add(clientServer);
m_regionData.Add(regionInfo);
udpServer.Start();
clientServer.Start();
if (do_post_init)
{
@ -561,7 +554,7 @@ namespace OpenSim
}
}
return udpServer;
return clientServer;
}
protected override StorageManager CreateStorageManager(string connectionstring)
@ -583,24 +576,23 @@ namespace OpenSim
public void handleRestartRegion(RegionInfo whichRegion)
{
m_log.Error("[OPENSIM MAIN]: Got restart signal from SceneManager");
// Shutting down the UDP server
bool foundUDPServer = false;
int UDPServerElement = 0;
// Shutting down the client server
bool foundClientServer = false;
int clientServerElement = 0;
for (int i = 0; i < m_clientServers.Count; i++)
{
if (m_clientServers[i].HandlesRegion(new Location(whichRegion.RegionHandle)))
{
UDPServerElement = i;
foundUDPServer = true;
clientServerElement = i;
foundClientServer = true;
break;
}
}
if (foundUDPServer)
if (foundClientServer)
{
// m_udpServers[UDPServerElement].Server.End
m_clientServers[UDPServerElement].Server.Close();
m_clientServers.RemoveAt(UDPServerElement);
m_clientServers[clientServerElement].Server.Close();
m_clientServers.RemoveAt(clientServerElement);
}
//Removing the region from the sim's database of regions..
@ -618,9 +610,6 @@ namespace OpenSim
}
CreateRegion(whichRegion, true);
//UDPServer restartingRegion = CreateRegion(whichRegion);
//restartingRegion.ServerListener();
//m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle);
}
# region Setup methods

View File

@ -38,7 +38,6 @@ using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Timer=System.Timers.Timer;

View File

@ -4915,7 +4915,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
catch (Exception)
{
//MainLog.Instance.Debug("UDPSERVER", e.ToString());
}
m_needAck.Add(key, packet);

View File

@ -107,12 +107,12 @@ namespace OpenSim.Region.ClientStack
return physicsPluginManager.GetPhysicsScene(engine, meshEngine);
}
protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer udpServer, bool m_permissions)
protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer, bool m_permissions)
{
return SetupScene(regionInfo, 0, out udpServer, m_permissions);
return SetupScene(regionInfo, 0, out clientServer, m_permissions);
}
protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out IClientNetworkServer udpServer, bool m_permissions)
protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out IClientNetworkServer clientServer, bool m_permissions)
{
AgentCircuitManager circuitManager = new AgentCircuitManager();
IPAddress listenIP = regionInfo.InternalEndPoint.Address;
@ -120,12 +120,12 @@ namespace OpenSim.Region.ClientStack
// listenIP = IPAddress.Parse("0.0.0.0");
uint port = (uint) regionInfo.InternalEndPoint.Port;
udpServer = new LLUDPServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager);
clientServer = new LLUDPServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager);
regionInfo.InternalEndPoint.Port = (int)port;
Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager);
udpServer.AddScene(scene);
clientServer.AddScene(scene);
scene.LoadWorldMap();

View File

@ -1594,8 +1594,6 @@ namespace OpenSim.Region.Environment.Scenes
client.OnMoveInventoryItem += MoveInventoryItem;
client.OnRemoveInventoryItem += RemoveInventoryItem;
client.OnRemoveInventoryFolder += RemoveInventoryFolder;
// client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
// client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
client.OnRezScript += RezScript;
client.OnRequestTaskInventory += RequestTaskInventory;

View File

@ -224,7 +224,7 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
/// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager
/// This works out to be the ClientView object associated with this avatar, or it's client connection manager
/// </summary>
private IClientAPI m_controllingClient;

View File

@ -39,7 +39,6 @@ using Mono.Addins;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
//using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Region.ClientStack;
using OpenSim.Region.ClientStack.LindenUDP;
using OpenSim.Region.Environment.Scenes;
@ -88,7 +87,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(SynchronizePacketRecieve);
sceneManager = openSim.SceneManager;
m_clientServers = openSim.UdpServers;
m_clientServers = openSim.ClientServers;
regionData = openSim.RegionData;
simMain = openSim;
commandServer = openSim.HttpServer;
@ -390,7 +389,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
return result;
}
private IClientNetworkServer SearchUDPServerFromPortNum(int portnum)
private IClientNetworkServer SearchClientServerFromPortNum(int portnum)
{
return m_clientServers.Find(delegate(IClientNetworkServer server) { return (portnum + proxyOffset == ((IPEndPoint)server.Server.LocalEndPoint).Port); });
}
@ -522,12 +521,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
Scene scene = null;
string[] files = null;
IClientAPI controller = null;
IClientNetworkServer udpserv = null;
IClientNetworkServer clientserv = null;
if (sceneManager.TryGetScene(dst_region.RegionID, out scene))
{
// search udpserver
udpserv = SearchUDPServerFromPortNum(scene.RegionInfo.InternalEndPoint.Port);
clientserv = SearchClientServerFromPortNum(scene.RegionInfo.InternalEndPoint.Port);
// restore the scene presence
for (int i = 0;; i++)
@ -565,9 +563,9 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
// BUG: Will only work with LLUDPServer.
// TODO: This needs to be abstracted and converted into IClientNetworkServer
if (udpserv is LLUDPServer)
if (clientserv is LLUDPServer)
{
((LLUDPServer) udpserv).RestoreClient(agentdata, data.userEP, data.proxyEP);
((LLUDPServer) clientserv).RestoreClient(agentdata, data.userEP, data.proxyEP);
}
// waiting for the scene-presense restored
@ -627,12 +625,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
}
// Shutting down the UDP server
IClientNetworkServer udpsvr = SearchUDPServerFromPortNum(port);
IClientNetworkServer clientsvr = SearchClientServerFromPortNum(port);
if (udpsvr != null)
if (clientsvr != null)
{
udpsvr.Server.Close();
m_clientServers.Remove(udpsvr);
clientsvr.Server.Close();
m_clientServers.Remove(clientsvr);
}
}

View File

@ -295,7 +295,7 @@ namespace OpenSim.ApplicationPlugins.RegionProxy
try
{
m_log.InfoFormat("[PROXY] Opening UDP socket on {0}", sd.clientEP);
m_log.InfoFormat("[PROXY] Opening special UDP socket on {0}", sd.clientEP);
sd.serverIP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), ((IPEndPoint) sd.clientEP).Port);
sd.server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sd.server.Bind(sd.serverIP);