Exemple #1
0
        /// <summary>
        /// Resynchronizes our remote presences with the given lists
        /// </summary>
        /// <param name="knownNeighborsDict">All known regions from both lists</param>
        /// <param name="deadRegions">Regions that we should not longer have presences on</param>
        /// <param name="newRegions">Regions that we should have presences on but do not</param>
        /// <returns></returns>
        private async Task ResyncRegions(Dictionary <ulong, SimpleRegionInfo> knownNeighborsDict, List <ulong> deadRegions, List <ulong> newRegions)
        {
            List <Task <Tuple <EstablishPresenceResult, string> > > connectionTasks = new List <Task <Tuple <EstablishPresenceResult, string> > >(newRegions.Count);
            List <Task> disconnectTasks = new List <Task>();

            foreach (var region in deadRegions)
            {
                disconnectTasks.Add(this.DropRemotePresence(knownNeighborsDict[region], false));
            }

            foreach (var region in newRegions)
            {
                connectionTasks.Add(this.EstablishPresenceOnRegion(knownNeighborsDict[region], false, false));
            }

            await Task.WhenAll(connectionTasks);

            await Task.WhenAll(disconnectTasks);

            if (connectionTasks.Count > 0)
            {
                if (_sp != null)
                {
                    _sp.SendChildAgentUpdate(); // send the other regions the intial avatar info (pos, draw distance) for culling
                }
            }
        }