diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index d5dc18f332..ba9c653003 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -339,12 +339,6 @@ namespace OpenSim.Client.MXP.PacketHandler
m_clients.Add(client);
m_log.Debug("[MXP ClientStack]: Created ClientView.");
-
- m_log.Debug("[MXP ClientStack]: Adding ClientView to Scene...");
- scene.ClientManager.Add(client.AgentId, client.RemoteEndPoint, client);
- m_log.Debug("[MXP ClientStack]: Added ClientView to Scene.");
-
-
client.MXPSendSynchronizationBegin(m_scenes[new UUID(joinRequestMessage.BubbleId)].SceneContents.GetTotalObjectsCount());
m_log.Debug("[MXP ClientStack]: Starting ClientView...");
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
index 9c24da5f92..e3abcf5bac 100644
--- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
+++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs
@@ -207,6 +207,11 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
get { throw new System.NotImplementedException(); }
}
+ public IPEndPoint RemoteEndPoint
+ {
+ get { throw new System.NotImplementedException(); }
+ }
+
public event GenericMessage OnGenericMessage = delegate { };
public event ImprovedInstantMessage OnInstantMessage = delegate { };
public event ChatMessage OnChatFromClient = delegate { };
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index aefe42516f..fd5f87f1e4 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -134,6 +134,20 @@ namespace OpenSim.Framework
}
}
+ public void Remove(UUID key)
+ {
+ lock (m_writeLock)
+ {
+ IClientAPI client;
+
+ if (m_dict.TryGetValue(key, out client))
+ {
+ m_dict = m_dict.Delete(key);
+ m_dict2 = m_dict2.Delete(client.RemoteEndPoint);
+ }
+ }
+ }
+
///
/// Resets the client collection
///
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index aecb3623de..0acf6e8bff 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -324,6 +324,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Properties
public LLUDPClient UDPClient { get { return m_udpClient; } }
+ public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
public UUID SecureSessionId { get { return m_secureSessionId; } }
public IScene Scene { get { return m_scene; } }
public UUID SessionId { get { return m_sessionId; } }
@@ -431,7 +432,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Remove ourselves from the scene
m_scene.RemoveClient(AgentId);
- m_scene.ClientManager.Remove(this);
//m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//GC.Collect();
@@ -586,11 +586,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
# region Setup
- ///
- /// Starts up the timers to check the client and resend unacked packets
- /// Adds the client to the OpenSim.Region.Framework.Scenes.Scene
- ///
- protected virtual void InitNewClient()
+ public virtual void Start()
{
m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate);
m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates);
@@ -609,59 +605,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
RefreshGroupMembership();
}
- public virtual void Start()
- {
- // This sets up all the timers
- InitNewClient();
- }
-
- ///
- /// Run a user session. This method lies at the base of the entire client thread.
- ///
- protected void RunUserSession()
- {
- try
- {
-
- }
- catch (Exception e)
- {
- if (e is ThreadAbortException)
- throw;
-
- if (StatsManager.SimExtraStats != null)
- StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
-
- // Don't let a failure in an individual client thread crash the whole sim.
- m_log.ErrorFormat(
- "[CLIENT]: Client thread for {0} {1} crashed. Logging them out.", Name, AgentId);
- m_log.Error(e.ToString());
-
- try
- {
- // Make an attempt to alert the user that their session has crashed
- AgentAlertMessagePacket packet
- = BuildAgentAlertPacket(
- "Unfortunately the session for this client on the server has crashed.\n"
- + "Any further actions taken will not be processed.\n"
- + "Please relog", true);
-
- OutPacket(packet, ThrottleOutPacketType.Unknown);
-
- // There may be a better way to do this. Perhaps kick? Not sure this propogates notifications to
- // listeners yet, though.
- Logout(this);
- }
- catch (Exception e2)
- {
- if (e2 is ThreadAbortException)
- throw;
-
- m_log.ErrorFormat("[CLIENT]: Further exception thrown on forced session logout. {0}", e2);
- }
- }
- }
-
# endregion
public void ActivateGesture(UUID assetId, UUID gestureId)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 22c275c984..8689af3712 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -646,7 +646,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
client.OnConnectionClosed += ConnectionClosedHandler;
// Start the IClientAPI
- m_scene.ClientManager.Add(client);
client.Start();
}
else
@@ -658,10 +657,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void RemoveClient(LLUDPClient udpClient)
{
- // Remove this client from the scene ClientManager
+ // Remove this client from the scene
IClientAPI client;
if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client))
- Util.FireAndForget(delegate(object o) { client.Close(); });
+ client.Close();
}
private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend)
@@ -810,19 +809,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void LogoutHandler(IClientAPI client)
{
client.OnLogout -= LogoutHandler;
-
client.SendLogoutPacket();
-
- if (client is LLClientView)
- RemoveClient(((LLClientView)client).UDPClient);
}
private void ConnectionClosedHandler(IClientAPI client)
{
client.OnConnectionClosed -= ConnectionClosedHandler;
-
- if (client is LLClientView)
- RemoveClient(((LLClientView)client).UDPClient);
+ RemoveClient(((LLClientView)client).UDPClient);
}
}
}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index dcee824fef..d651fd413f 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -833,6 +833,11 @@ namespace OpenSim.Region.Examples.SimpleModule
set { m_circuitCode = value; }
}
+ public IPEndPoint RemoteEndPoint
+ {
+ get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); }
+ }
+
public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
{
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index bb718960af..7944548c81 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2363,6 +2363,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public override void AddNewClient(IClientAPI client)
{
+ ClientManager.Add(client);
+
CheckHeartbeat();
SubscribeToClientEvents(client);
ScenePresence presence;
@@ -3002,7 +3004,9 @@ namespace OpenSim.Region.Framework.Scenes
agentTransactions.RemoveAgentAssetTransactions(agentID);
}
+ // Remove the avatar from the scene
m_sceneGraph.RemoveScenePresence(agentID);
+ ClientManager.Remove(agentID);
try
{
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
index c962329a45..4c2a4b9785 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
@@ -64,7 +64,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView
void user_OnIRCReady(IRCClientView cv)
{
m_log.Info("[IRCd] Adding user...");
- m_scene.ClientManager.Add(cv.AgentId, cv.RemoteEndPoint, cv);
cv.Start();
m_log.Info("[IRCd] Added user to Scene");
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index eb7b0d77dd..41a6255c39 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -155,7 +155,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
NPCAvatar npcAvatar = new NPCAvatar(p_firstname, p_lastname, p_position, p_scene);
npcAvatar.CircuitCode = (uint) Util.RandomClass.Next(0, int.MaxValue);
- p_scene.ClientManager.Add(npcAvatar.AgentId, npcAvatar.RemoteEndPoint, npcAvatar);
p_scene.AddNewClient(npcAvatar);
ScenePresence sp;
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index ad90817ac1..5c838c5627 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -393,6 +393,11 @@ namespace OpenSim.Tests.Common.Mock
set { m_circuitCode = value; }
}
+ public IPEndPoint RemoteEndPoint
+ {
+ get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); }
+ }
+
///
/// Constructor
///
diff --git a/prebuild.xml b/prebuild.xml
index f15fadfe74..1a491a7cd7 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3497,7 +3497,6 @@
-