mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 04:05:42 +08:00
c# sugar
This commit is contained in:
@@ -97,7 +97,7 @@ namespace OpenSim.Framework
|
||||
/// <summary>
|
||||
/// Agent's full name.
|
||||
/// </summary>
|
||||
public string Name { get { return string.Format("{0} {1}", firstname, lastname); } }
|
||||
public string Name { get { return $"{firstname} {lastname}"; } }
|
||||
|
||||
/// <summary>
|
||||
/// Random Unique GUID for this session. Client gets this at login and it's
|
||||
@@ -139,13 +139,13 @@ namespace OpenSim.Framework
|
||||
get
|
||||
{
|
||||
// Old style version string contains viewer name followed by a space followed by a version number
|
||||
if (m_viewerInternal == null || m_viewerInternal.Contains(" "))
|
||||
if (m_viewerInternal is null || m_viewerInternal.Contains(' '))
|
||||
{
|
||||
return m_viewerInternal;
|
||||
}
|
||||
else // New style version contains no spaces, just version number
|
||||
{
|
||||
return Channel + " " + m_viewerInternal;
|
||||
return $"{Channel} {m_viewerInternal}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,14 +183,16 @@ namespace OpenSim.Framework
|
||||
/// <returns>map of the agent circuit data</returns>
|
||||
public OSDMap PackAgentCircuitData(EntityTransferContext ctx)
|
||||
{
|
||||
OSDMap args = new OSDMap();
|
||||
args["agent_id"] = OSD.FromUUID(AgentID);
|
||||
args["base_folder"] = OSD.FromUUID(BaseFolder);
|
||||
args["caps_path"] = OSD.FromString(CapsPath);
|
||||
|
||||
if (ChildrenCapSeeds != null)
|
||||
OSDMap args = new()
|
||||
{
|
||||
OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
|
||||
["agent_id"] = OSD.FromUUID(AgentID),
|
||||
["base_folder"] = OSD.FromUUID(BaseFolder),
|
||||
["caps_path"] = OSD.FromString(CapsPath)
|
||||
};
|
||||
|
||||
if (ChildrenCapSeeds is not null)
|
||||
{
|
||||
OSDArray childrenSeeds = new(ChildrenCapSeeds.Count);
|
||||
foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
|
||||
{
|
||||
OSDMap pair = new OSDMap();
|
||||
|
||||
@@ -42,36 +42,38 @@ namespace OpenSim.Framework
|
||||
/// <remarks>
|
||||
/// We lock this for operations both on this dictionary and on m_agentCircuitsByUUID
|
||||
/// </remarks>
|
||||
private ConcurrentDictionary<uint, AgentCircuitData> m_agentCircuits = new ConcurrentDictionary<uint, AgentCircuitData>();
|
||||
private readonly ConcurrentDictionary<uint, AgentCircuitData> m_agentCircuits = new();
|
||||
|
||||
/// <summary>
|
||||
/// Agent circuits indexed by agent UUID.
|
||||
/// </summary>
|
||||
private ConcurrentDictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new ConcurrentDictionary<UUID, AgentCircuitData>();
|
||||
private readonly ConcurrentDictionary<UUID, AgentCircuitData> m_agentCircuitsByUUID = new();
|
||||
|
||||
public virtual AuthenticateResponse AuthenticateSession(UUID sessionID, UUID agentID, uint circuitcode)
|
||||
{
|
||||
AuthenticateResponse user = new AuthenticateResponse();
|
||||
if (!m_agentCircuits.TryGetValue(circuitcode, out AgentCircuitData validcircuit) || validcircuit == null)
|
||||
AuthenticateResponse user = new();
|
||||
if (!m_agentCircuits.TryGetValue(circuitcode, out AgentCircuitData validcircuit) || validcircuit is null)
|
||||
{
|
||||
//don't have this circuit code in our list
|
||||
user.Authorised = false;
|
||||
return user;
|
||||
}
|
||||
|
||||
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
|
||||
if (sessionID.Equals(validcircuit.SessionID) && agentID.Equals(validcircuit.AgentID))
|
||||
{
|
||||
user.Authorised = true;
|
||||
user.LoginInfo = new Login();
|
||||
user.LoginInfo.Agent = agentID;
|
||||
user.LoginInfo.Session = sessionID;
|
||||
user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
|
||||
user.LoginInfo.First = validcircuit.firstname;
|
||||
user.LoginInfo.Last = validcircuit.lastname;
|
||||
user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
|
||||
user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
|
||||
user.LoginInfo.StartPos = validcircuit.startpos;
|
||||
user.LoginInfo.StartFar = (float)validcircuit.startfar;
|
||||
user.LoginInfo = new Login
|
||||
{
|
||||
Agent = agentID,
|
||||
Session = sessionID,
|
||||
SecureSession = validcircuit.SecureSessionID,
|
||||
First = validcircuit.firstname,
|
||||
Last = validcircuit.lastname,
|
||||
InventoryFolder = validcircuit.InventoryFolder,
|
||||
BaseFolder = validcircuit.BaseFolder,
|
||||
StartPos = validcircuit.startpos,
|
||||
StartFar = validcircuit.startfar
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,7 +108,7 @@ namespace OpenSim.Framework
|
||||
{
|
||||
if (m_agentCircuits.TryRemove(circuitCode, out AgentCircuitData ac))
|
||||
{
|
||||
m_agentCircuitsByUUID.TryRemove(ac.AgentID, out AgentCircuitData dummy);
|
||||
m_agentCircuitsByUUID.TryRemove(ac.AgentID, out AgentCircuitData _);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,16 +116,16 @@ namespace OpenSim.Framework
|
||||
{
|
||||
if (m_agentCircuitsByUUID.TryRemove(agentID, out AgentCircuitData ac))
|
||||
{
|
||||
m_agentCircuits.TryRemove(ac.circuitcode, out AgentCircuitData dummy);
|
||||
m_agentCircuits.TryRemove(ac.circuitcode, out AgentCircuitData _);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveCircuit(AgentCircuitData ac)
|
||||
{
|
||||
m_agentCircuitsByUUID.TryRemove(ac.AgentID, out AgentCircuitData dummy);
|
||||
m_agentCircuits.TryRemove(ac.circuitcode, out AgentCircuitData dummyb);
|
||||
if (dummy!= null && dummy.circuitcode != ac.circuitcode) //??
|
||||
m_agentCircuits.TryRemove(dummy.circuitcode, out AgentCircuitData dummyc);
|
||||
m_agentCircuitsByUUID.TryRemove(ac.AgentID, out AgentCircuitData byuuid);
|
||||
m_agentCircuits.TryRemove(ac.circuitcode, out AgentCircuitData _);
|
||||
if (byuuid is not null && byuuid.circuitcode != ac.circuitcode) //??
|
||||
m_agentCircuits.TryRemove(byuuid.circuitcode, out AgentCircuitData _);
|
||||
}
|
||||
|
||||
public AgentCircuitData GetAgentCircuitData(uint circuitCode)
|
||||
|
||||
@@ -40,15 +40,15 @@ namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>A dictionary mapping from <seealso cref="UUID"/>
|
||||
/// to <seealso cref="IClientAPI"/> references</summary>
|
||||
private readonly Dictionary<UUID, IClientAPI> m_dictbyUUID = new Dictionary<UUID, IClientAPI>();
|
||||
private readonly Dictionary<UUID, IClientAPI> m_dictbyUUID = new();
|
||||
/// <summary>A dictionary mapping from <seealso cref="IPEndPoint"/>
|
||||
/// to <seealso cref="IClientAPI"/> references</summary>
|
||||
private readonly Dictionary<IPEndPoint, IClientAPI> m_dictbyIPe= new Dictionary<IPEndPoint, IClientAPI>();
|
||||
private readonly Dictionary<IPEndPoint, IClientAPI> m_dictbyIPe= new();
|
||||
/// <summary>snapshot collection of current <seealso cref="IClientAPI"/>
|
||||
/// references</summary>
|
||||
private IClientAPI[] m_array = null;
|
||||
/// <summary>Synchronization object for writing to the collections</summary>
|
||||
private readonly object m_syncRoot = new object();
|
||||
private readonly object m_syncRoot = new();
|
||||
|
||||
/// <summary>Number of clients in the collection</summary>
|
||||
public int Count
|
||||
@@ -96,10 +96,8 @@ namespace OpenSim.Framework
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
{
|
||||
IClientAPI value;
|
||||
if (m_dictbyUUID.TryGetValue(key, out value))
|
||||
if (m_dictbyUUID.Remove(key, out IClientAPI value))
|
||||
{
|
||||
m_dictbyUUID.Remove(key);
|
||||
m_dictbyIPe.Remove(value.RemoteEndPoint);
|
||||
m_array = null;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user