aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/UDPServer.cs
diff options
context:
space:
mode:
authorMW2007-05-16 13:10:17 +0000
committerMW2007-05-16 13:10:17 +0000
commitfd67b36a5eb3623b9f98b1fc11ea3e5b607c5901 (patch)
treebcd8f437ea29acc0438a4700b04293605dbba5e9 /OpenSim.RegionServer/UDPServer.cs
parentstarted to refactor startup code and to move udp server code out to its own c... (diff)
downloadopensim-SC-fd67b36a5eb3623b9f98b1fc11ea3e5b607c5901.zip
opensim-SC-fd67b36a5eb3623b9f98b1fc11ea3e5b607c5901.tar.gz
opensim-SC-fd67b36a5eb3623b9f98b1fc11ea3e5b607c5901.tar.bz2
opensim-SC-fd67b36a5eb3623b9f98b1fc11ea3e5b607c5901.tar.xz
UDPServer enabled, should no longer be any udp server code in OpenSimMain.
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/UDPServer.cs36
1 files changed, 27 insertions, 9 deletions
diff --git a/OpenSim.RegionServer/UDPServer.cs b/OpenSim.RegionServer/UDPServer.cs
index e70ae78..89c4f67 100644
--- a/OpenSim.RegionServer/UDPServer.cs
+++ b/OpenSim.RegionServer/UDPServer.cs
@@ -46,11 +46,31 @@ namespace OpenSim
46 private bool user_accounts = false; 46 private bool user_accounts = false;
47 private ConsoleBase m_console; 47 private ConsoleBase m_console;
48 48
49 public UDPServer(int port, Grid gridServers, World localWorld, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console) 49 public PacketServer PacketServer
50 {
51 get
52 {
53 return _packetServer;
54 }
55 set
56 {
57 _packetServer = value;
58 }
59 }
60
61 public World LocalWorld
62 {
63 set
64 {
65 this.m_localWorld = value;
66 this._packetServer.LocalWorld = this.m_localWorld;
67 }
68 }
69
70 public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console)
50 { 71 {
51 listenPort = port; 72 listenPort = port;
52 this.m_gridServers = gridServers; 73 this.m_gridServers = gridServers;
53 this.m_localWorld = localWorld;
54 this.m_assetCache = assetCache; 74 this.m_assetCache = assetCache;
55 this.m_inventoryCache = inventoryCache; 75 this.m_inventoryCache = inventoryCache;
56 this.m_regionData = _regionData; 76 this.m_regionData = _regionData;
@@ -58,8 +78,6 @@ namespace OpenSim
58 this.user_accounts = accounts; 78 this.user_accounts = accounts;
59 this.m_console = console; 79 this.m_console = console;
60 PacketServer packetServer = new PacketServer(this); 80 PacketServer packetServer = new PacketServer(this);
61 this._packetServer.LocalWorld = m_localWorld;
62 this._packetServer.RegisterClientPacketHandlers();
63 } 81 }
64 82
65 protected virtual void OnReceivedData(IAsyncResult result) 83 protected virtual void OnReceivedData(IAsyncResult result)
@@ -85,7 +103,7 @@ namespace OpenSim
85 } 103 }
86 else 104 else
87 { // invalid client 105 { // invalid client
88 Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); 106 Console.Error.WriteLine("UDPServer.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
89 } 107 }
90 108
91 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 109 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
@@ -106,22 +124,22 @@ namespace OpenSim
106 this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); 124 this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
107 } 125 }
108 126
109 private void ServerListener() 127 public void ServerListener()
110 { 128 {
111 m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + listenPort); 129 m_console.WriteLine("UDPServer.cs:ServerListener() - Opening UDP socket on " + listenPort);
112 130
113 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort); 131 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
114 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 132 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
115 Server.Bind(ServerIncoming); 133 Server.Bind(ServerIncoming);
116 134
117 m_console.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); 135 m_console.WriteLine("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen");
118 136
119 ipeSender = new IPEndPoint(IPAddress.Any, 0); 137 ipeSender = new IPEndPoint(IPAddress.Any, 0);
120 epSender = (EndPoint)ipeSender; 138 epSender = (EndPoint)ipeSender;
121 ReceivedData = new AsyncCallback(this.OnReceivedData); 139 ReceivedData = new AsyncCallback(this.OnReceivedData);
122 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 140 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
123 141
124 m_console.WriteLine("Main.cs:MainServerListener() - Listening..."); 142 m_console.WriteLine("UDPServer.cs:ServerListener() - Listening...");
125 143
126 } 144 }
127 145