aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs58
1 files changed, 39 insertions, 19 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index ccad241..7db5f6b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -894,11 +894,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
894 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; 894 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
895 895
896 // Begin the process of adding the client to the simulator 896 // Begin the process of adding the client to the simulator
897 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 897 IClientAPI client = AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
898 898
899 // Send ack 899 // Send ack straight away to let the viewer know that the connection is active.
900 SendAckImmediate(remoteEndPoint, packet.Header.Sequence); 900 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
901 901
902 // FIXME: Nasty - this is the only way we currently know if Scene.AddNewClient() failed to find a
903 // circuit and bombed out early. That check might be pointless since authorization is established
904 // up here.
905 if (client != null && client.SceneAgent != null)
906 client.SceneAgent.SendInitialDataToMe();
907
902 // m_log.DebugFormat( 908 // m_log.DebugFormat(
903// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 909// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
904// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); 910// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
@@ -933,7 +939,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
933 return sessionInfo.Authorised; 939 return sessionInfo.Authorised;
934 } 940 }
935 941
936 private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint) 942 /// <summary>
943 /// Add a new client.
944 /// </summary>
945 /// <param name="useCircuitCode"></param>
946 /// <param name="remoteEndPoint"></param>
947 /// <returns>
948 /// The client that was added or null if the client failed authorization or already existed.
949 /// </returns>
950 private IClientAPI AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
937 { 951 {
938 UUID agentID = useCircuitCode.CircuitCode.ID; 952 UUID agentID = useCircuitCode.CircuitCode.ID;
939 UUID sessionID = useCircuitCode.CircuitCode.SessionID; 953 UUID sessionID = useCircuitCode.CircuitCode.SessionID;
@@ -942,7 +956,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
942 AuthenticateResponse sessionInfo; 956 AuthenticateResponse sessionInfo;
943 if (IsClientAuthorized(useCircuitCode, out sessionInfo)) 957 if (IsClientAuthorized(useCircuitCode, out sessionInfo))
944 { 958 {
945 AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo); 959 return AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
946 } 960 }
947 else 961 else
948 { 962 {
@@ -950,38 +964,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
950 m_log.WarnFormat( 964 m_log.WarnFormat(
951 "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", 965 "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
952 useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint); 966 useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
967
968 return null;
953 } 969 }
954 } 970 }
955 971
956 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 972 /// <summary>
973 /// Add a client.
974 /// </summary>
975 /// <param name="circuitCode"></param>
976 /// <param name="agentID"></param>
977 /// <param name="sessionID"></param>
978 /// <param name="remoteEndPoint"></param>
979 /// <param name="sessionInfo"></param>
980 /// <returns>The client if it was added. Null if the client already existed.</returns>
981 protected virtual IClientAPI AddClient(
982 uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
957 { 983 {
984 IClientAPI client = null;
985
958 // In priciple there shouldn't be more than one thread here, ever. 986 // In priciple there shouldn't be more than one thread here, ever.
959 // But in case that happens, we need to synchronize this piece of code 987 // But in case that happens, we need to synchronize this piece of code
960 // because it's too important 988 // because it's too important
961 lock (this) 989 lock (this)
962 { 990 {
963 IClientAPI existingClient; 991 if (!m_scene.TryGetClient(agentID, out client))
964
965 if (!m_scene.TryGetClient(agentID, out existingClient))
966 { 992 {
967 // Create the LLUDPClient
968 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); 993 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
969 // Create the LLClientView 994
970 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 995 client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
971 client.OnLogout += LogoutHandler; 996 client.OnLogout += LogoutHandler;
972 997
973 client.DisableFacelights = m_disableFacelights; 998 ((LLClientView)client).DisableFacelights = m_disableFacelights;
974 999
975 // Start the IClientAPI
976 client.Start(); 1000 client.Start();
977
978 }
979 else
980 {
981 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
982 existingClient.AgentId, remoteEndPoint, circuitCode);
983 } 1001 }
984 } 1002 }
1003
1004 return client;
985 } 1005 }
986 1006
987 private void RemoveClient(LLUDPClient udpClient) 1007 private void RemoveClient(LLUDPClient udpClient)