OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
/// <summary>
/// Send updated position information about an agent in this region to a neighbor
/// This operation may be called very frequently if an avatar is moving about in
/// the region.
/// </summary>
Send updated position information about an agent in this region to a neighbor
This operation may be called very frequently if an avatar is moving about in
the region.
Send updated position information about an agent in this region to a neighbor This operation may be called very frequently if an avatar is moving about in the region .
public bool UpdateAgent(GridRegion destination, AgentPosition data)
        {
            bool v = true;
            if (_failedSims.TryGetValue(destination.ServerURI, out v))
                return false;
            string uri = destination.ServerURI + AgentPath() + data.AgentID + "/";
            lock (m_updateAgentQueue)
            {
                if (m_updateAgentQueue.ContainsKey(uri))
                {
                    m_updateAgentQueue[uri] = data;
                    return true;
                }
                m_updateAgentQueue[uri] = data;
            }
            AgentPosition pos = null;
            bool success = true;
            while (success)
            {
                lock (m_updateAgentQueue)
                {
                    AgentPosition lastpos = pos;
                    pos = m_updateAgentQueue[uri];
                    if (pos == lastpos)
                    {
                        m_updateAgentQueue.Remove(uri);
                        return true;
                    }
                }
                success = UpdateAgent(destination, (IAgentData)pos, 10000);
            }
            lock (m_updateAgentQueue)
            {
                _failedSims.AddOrUpdate(destination.ServerURI, true, 120);
                m_updateAgentQueue.Remove(uri);
            }
            return false;
        }
public bool UpdateAgent ( GridRegion destination , AgentPosition data ) { bool v = true ; if ( _failedSims . TryGetValue ( destination . ServerURI , out v ) ) return false ; string uri = destination . ServerURI + AgentPath ( ) + data . AgentID + " " ; lock ( m_updateAgentQueue ) { if ( m_updateAgentQueue . ContainsKey ( uri ) ) { m_updateAgentQueue [ uri ] = data ; return true ; } m_updateAgentQueue [ uri ] = data ; } AgentPosition pos = null ; bool success = true ; while ( success ) { lock ( m_updateAgentQueue ) { AgentPosition lastpos = pos ; pos = m_updateAgentQueue [ uri ] ; if ( pos == lastpos ) { m_updateAgentQueue . Remove ( uri ) ; return true ; } } success = UpdateAgent ( destination , ( IAgentData ) pos , 10000 ) ; } lock ( m_updateAgentQueue ) { _failedSims . AddOrUpdate ( destination . ServerURI , true , 120 ) ; m_updateAgentQueue . Remove ( uri ) ; } return false ; }
Send updated position information about an agent in this region to a neighbor
This operation may be called very frequently if an avatar is moving about in
the region.
Send updated position information about an agent in this region to a neighbor This operation may be called very frequently if an avatar is moving about in the region .
// The basic idea of this code is that the first thread that needs to // send an update for a specific avatar becomes the worker for any subsequent // requests until there are no more outstanding requests. Further, only send the most // recent update; this *should* never be needed but some requests get // slowed down and once that happens the problem with service end point // limits kicks in and nothing proceeds // Another thread is already handling  // updates for this simulator, just update  // the position and return, overwrites are // not a problem since we only care about the // last update anyway // Otherwise update the reference and start processing // save the position // this is true if no one put a new // update in the map since the last // one we processed, if thats the // case then we are done // we get here iff success == false // blacklist sim for 2 minutes
destination
GridRegion
data
AgentPosition