diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 1e6927f..7052e0e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -96,7 +96,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
96 | /// <summary>Incoming packets that are awaiting handling</summary> | 96 | /// <summary>Incoming packets that are awaiting handling</summary> |
97 | private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); | 97 | private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); |
98 | /// <summary></summary> | 98 | /// <summary></summary> |
99 | private UDPClientCollection clients = new UDPClientCollection(); | 99 | private UDPClientCollection m_clients = new UDPClientCollection(); |
100 | /// <summary>Bandwidth throttle for this UDP server</summary> | 100 | /// <summary>Bandwidth throttle for this UDP server</summary> |
101 | private TokenBucket m_throttle; | 101 | private TokenBucket m_throttle; |
102 | /// <summary>Bandwidth throttle rates for this UDP server</summary> | 102 | /// <summary>Bandwidth throttle rates for this UDP server</summary> |
@@ -115,7 +115,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
115 | public Socket Server { get { return null; } } | 115 | public Socket Server { get { return null; } } |
116 | 116 | ||
117 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | 117 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) |
118 | : base((int)port) | 118 | : base(listenIP, (int)port) |
119 | { | 119 | { |
120 | #region Environment.TickCount Measurement | 120 | #region Environment.TickCount Measurement |
121 | 121 | ||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
143 | public new void Start() | 143 | public new void Start() |
144 | { | 144 | { |
145 | if (m_scene == null) | 145 | if (m_scene == null) |
146 | throw new InvalidOperationException("Cannot LLUDPServer.Start() without an IScene reference"); | 146 | throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference"); |
147 | 147 | ||
148 | base.Start(); | 148 | base.Start(); |
149 | 149 | ||
@@ -181,22 +181,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
181 | return x == m_location; | 181 | return x == m_location; |
182 | } | 182 | } |
183 | 183 | ||
184 | public void RemoveClient(IClientAPI client) | 184 | public void RemoveClient(LLUDPClient udpClient) |
185 | { | 185 | { |
186 | m_scene.ClientManager.Remove(client.CircuitCode); | 186 | m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + udpClient.ClientAPI.Name); |
187 | client.Close(false); | ||
188 | 187 | ||
189 | LLUDPClient udpClient; | 188 | m_scene.ClientManager.Remove(udpClient.CircuitCode); |
190 | if (clients.TryGetValue(client.AgentId, out udpClient)) | 189 | udpClient.ClientAPI.Close(false); |
191 | { | 190 | udpClient.Shutdown(); |
192 | m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + client.Name); | 191 | m_clients.Remove(udpClient.RemoteEndPoint); |
193 | udpClient.Shutdown(); | ||
194 | clients.Remove(client.AgentId, udpClient.RemoteEndPoint); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | m_log.Warn("[LLUDPSERVER]: Failed to remove LLUDPClient for " + client.Name); | ||
199 | } | ||
200 | } | 192 | } |
201 | 193 | ||
202 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) | 194 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) |
@@ -216,7 +208,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
216 | for (int i = 0; i < packetCount; i++) | 208 | for (int i = 0; i < packetCount; i++) |
217 | { | 209 | { |
218 | byte[] data = datas[i]; | 210 | byte[] data = datas[i]; |
219 | clients.ForEach( | 211 | m_clients.ForEach( |
220 | delegate(LLUDPClient client) | 212 | delegate(LLUDPClient client) |
221 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); | 213 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); |
222 | } | 214 | } |
@@ -224,21 +216,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
224 | else | 216 | else |
225 | { | 217 | { |
226 | byte[] data = packet.ToBytes(); | 218 | byte[] data = packet.ToBytes(); |
227 | clients.ForEach( | 219 | m_clients.ForEach( |
228 | delegate(LLUDPClient client) | 220 | delegate(LLUDPClient client) |
229 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); | 221 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); |
230 | } | 222 | } |
231 | } | 223 | } |
232 | 224 | ||
233 | public void SendPacket(UUID agentID, Packet packet, ThrottleOutPacketType category, bool allowSplitting) | ||
234 | { | ||
235 | LLUDPClient client; | ||
236 | if (clients.TryGetValue(agentID, out client)) | ||
237 | SendPacket(client, packet, category, allowSplitting); | ||
238 | else | ||
239 | m_log.Warn("[LLUDPSERVER]: Attempted to send a packet to unknown agentID " + agentID); | ||
240 | } | ||
241 | |||
242 | public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting) | 225 | public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting) |
243 | { | 226 | { |
244 | // CoarseLocationUpdate packets cannot be split in an automated way | 227 | // CoarseLocationUpdate packets cannot be split in an automated way |
@@ -391,7 +374,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
391 | { | 374 | { |
392 | m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.ClientAPI.Name); | 375 | m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.ClientAPI.Name); |
393 | 376 | ||
394 | RemoveClient(client.ClientAPI); | 377 | RemoveClient(client); |
395 | return; | 378 | return; |
396 | } | 379 | } |
397 | } | 380 | } |
@@ -519,9 +502,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
519 | } | 502 | } |
520 | 503 | ||
521 | // Determine which agent this packet came from | 504 | // Determine which agent this packet came from |
522 | if (!clients.TryGetValue(address, out client)) | 505 | if (!m_clients.TryGetValue(address, out client)) |
523 | { | 506 | { |
524 | m_log.Warn("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address); | 507 | m_log.Warn("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + |
508 | ", currently tracking " + m_clients.Count + " clients"); | ||
525 | return; | 509 | return; |
526 | } | 510 | } |
527 | 511 | ||
@@ -623,7 +607,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
623 | if (m_scene.RegionStatus != RegionStatus.SlaveScene) | 607 | if (m_scene.RegionStatus != RegionStatus.SlaveScene) |
624 | { | 608 | { |
625 | AuthenticateResponse sessionInfo; | 609 | AuthenticateResponse sessionInfo; |
626 | bool isNewCircuit = !clients.ContainsKey(remoteEndPoint); | 610 | bool isNewCircuit = !m_clients.ContainsKey(remoteEndPoint); |
627 | 611 | ||
628 | if (!IsClientAuthorized(useCircuitCode, out sessionInfo)) | 612 | if (!IsClientAuthorized(useCircuitCode, out sessionInfo)) |
629 | { | 613 | { |
@@ -647,23 +631,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
647 | private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) | 631 | private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) |
648 | { | 632 | { |
649 | // Create the LLUDPClient | 633 | // Create the LLUDPClient |
650 | LLUDPClient client = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); | 634 | LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); |
651 | 635 | ||
652 | // Create the LLClientView | 636 | // Create the LLClientView |
653 | LLClientView clientApi = new LLClientView(remoteEndPoint, m_scene, this, client, sessionInfo, agentID, sessionID, circuitCode); | 637 | LLClientView clientApi = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); |
654 | clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; | 638 | clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; |
655 | clientApi.OnLogout += LogoutHandler; | 639 | clientApi.OnLogout += LogoutHandler; |
656 | clientApi.OnConnectionClosed += RemoveClient; | 640 | clientApi.OnConnectionClosed += |
641 | delegate(IClientAPI client) | ||
642 | { if (client is LLClientView) RemoveClient(((LLClientView)client).UDPClient); }; | ||
657 | 643 | ||
658 | // Start the IClientAPI | 644 | // Start the IClientAPI |
659 | m_scene.ClientManager.Add(circuitCode, clientApi); | 645 | m_scene.ClientManager.Add(circuitCode, clientApi); |
660 | clientApi.Start(); | 646 | clientApi.Start(); |
661 | 647 | ||
662 | // Give LLUDPClient a reference to IClientAPI | 648 | // Give LLUDPClient a reference to IClientAPI |
663 | client.ClientAPI = clientApi; | 649 | udpClient.ClientAPI = clientApi; |
664 | 650 | ||
665 | // Add the new client to our list of tracked clients | 651 | // Add the new client to our list of tracked clients |
666 | clients.Add(agentID, client.RemoteEndPoint, client); | 652 | m_clients.Add(udpClient.RemoteEndPoint, udpClient); |
667 | } | 653 | } |
668 | 654 | ||
669 | private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend) | 655 | private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend) |
@@ -741,7 +727,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
741 | elapsed500MS = 0; | 727 | elapsed500MS = 0; |
742 | } | 728 | } |
743 | 729 | ||
744 | clients.ForEach( | 730 | m_clients.ForEach( |
745 | delegate(LLUDPClient client) | 731 | delegate(LLUDPClient client) |
746 | { | 732 | { |
747 | if (client.DequeueOutgoing()) | 733 | if (client.DequeueOutgoing()) |
@@ -798,7 +784,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
798 | private void LogoutHandler(IClientAPI client) | 784 | private void LogoutHandler(IClientAPI client) |
799 | { | 785 | { |
800 | client.SendLogoutPacket(); | 786 | client.SendLogoutPacket(); |
801 | RemoveClient(client); | 787 | if (client is LLClientView) |
788 | RemoveClient(((LLClientView)client).UDPClient); | ||
802 | } | 789 | } |
803 | } | 790 | } |
804 | } | 791 | } |