public void OnMemberJoined(UUID AgentId)
        {
            if (AgentId == client.Self.AgentID)
            {
                return;
            }
            var changes   = new ChannelMemberChangeEventArgs();
            var newmember = new ChannelMemberChangeEventArgs.ChangeDetails();

            newmember.Subject     = mapper.MapUser(AgentId);
            newmember.NewPosition = PositionCategory.Distant;
            newmember.OldPosition = PositionCategory.Distant;
            client.Self.GroupChatSessions.Lock(d =>
            {
                var cachedMembership = d[group.ID].FirstOrDefault(i => i.AvatarKey == AgentId);
                if (cachedMembership.AvatarKey == AgentId)
                {
                    newmember.IsOperator = cachedMembership.IsModerator;
                }
            });
            changes.NewMembers.Add(newmember);

            if (MembersChanged != null)
            {
                MembersChanged(this, changes);
            }
        }
        public void OnMemberLeft(UUID AgentId)
        {
            if (AgentId == client.Self.AgentID)
            {
                return;
            }
            var changes   = new ChannelMemberChangeEventArgs();
            var oldmember = new ChannelMemberChangeEventArgs.ChangeDetails();

            oldmember.Subject = mapper.MapUser(AgentId);
            changes.RemovedMembers.Add(oldmember);
            if (MembersChanged != null)
            {
                MembersChanged(this, changes);
            }
        }
Exemple #3
0
        public void OnLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            var evt = new ChannelMemberChangeEventArgs();
            Dictionary <UUID, ChannelMembership> nearbyAvatars;

            if (e.Simulator.Name != client.Network.CurrentSim.Name)
            {
                return;
            }

            if (!nearby.TryGetValue(e.Simulator.Name, out nearbyAvatars))
            {
                nearbyAvatars = new Dictionary <UUID, ChannelMembership>();
                nearby.Add(e.Simulator.Name, nearbyAvatars);
            }

            foreach (var i in e.NewEntries)
            {
                if (i == client.Self.AgentID)
                {
                    continue;
                }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                detail.Subject     = mapper.MapUser(i);
                detail.IsOperator  = false;
                detail.WasOperator = false;
                detail.NewPosition = CategorisePosition(i, e);
                detail.OldPosition = PositionCategory.Distant;
                evt.NewMembers.Add(detail);

                var membership = new ChannelMembership();
                membership.Subject    = detail.Subject;
                membership.IsOperator = false;
                membership.Position   = CategorisePosition(i, e);
                if (nearbyAvatars.ContainsKey(i))
                {
                    nearbyAvatars[i] = membership;
                }
                else
                {
                    nearbyAvatars.Add(i, membership);
                }
            }

            foreach (var i in e.RemovedEntries)
            {
                if (i == client.Self.AgentID)
                {
                    continue;
                }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                if (nearbyAvatars.ContainsKey(i))
                {
                    detail.Subject     = nearbyAvatars[i].Subject;
                    detail.IsOperator  = false;
                    detail.WasOperator = false;
                    detail.NewPosition = PositionCategory.Distant;
                    detail.OldPosition = nearbyAvatars[i].Position;
                    evt.RemovedMembers.Add(detail);

                    nearbyAvatars.Remove(i);
                }
            }

            foreach (var i in nearbyAvatars)
            {
                if (i.Key == client.Self.AgentID)
                {
                    continue;
                }

                var newpos = CategorisePosition(i.Key, e);
                if (i.Value.Position != newpos)
                {
                    var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                    detail.Subject     = nearbyAvatars[i.Key].Subject;
                    detail.IsOperator  = false;
                    detail.WasOperator = false;
                    detail.NewPosition = newpos;
                    detail.OldPosition = nearbyAvatars[i.Key].Position;
                    evt.ChangedMembers.Add(detail);
                    nearbyAvatars[i.Key].Position = newpos;
                }
            }

            if (!evt.HasChanges)
            {
                return;
            }

            lock (syncRoot)
            {
                if (state != ChannelState.Connected)
                {
                    state = ChannelState.Connected;
                    joinTask.SetResult(true);
                }
            }

            if (this.MembersChanged != null)
            {
                MembersChanged(this, evt);
            }
        }
        public void OnLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            var evt = new ChannelMemberChangeEventArgs();
            Dictionary<UUID, ChannelMembership> nearbyAvatars;

            if (e.Simulator.Name != client.Network.CurrentSim.Name) return;

            if(!nearby.TryGetValue(e.Simulator.Name, out nearbyAvatars))
            {
                nearbyAvatars = new Dictionary<UUID, ChannelMembership>();
                nearby.Add(e.Simulator.Name, nearbyAvatars);
            }

            foreach(var i in e.NewEntries)
            {
                if (i == client.Self.AgentID) { continue; }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                detail.Subject = mapper.MapUser(i);
                detail.IsOperator = false;
                detail.WasOperator = false;
                detail.NewPosition = CategorisePosition(i, e);
                detail.OldPosition = PositionCategory.Distant;
                evt.NewMembers.Add(detail);

                var membership = new ChannelMembership();
                membership.Subject = detail.Subject;
                membership.IsOperator = false;
                membership.Position = CategorisePosition(i, e);
                if (nearbyAvatars.ContainsKey(i))
                {
                    nearbyAvatars[i] = membership;
                }
                else
                {
                    nearbyAvatars.Add(i, membership);
                }
            }

            foreach(var i in e.RemovedEntries)
            {
                if (i == client.Self.AgentID) { continue; }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                if (nearbyAvatars.ContainsKey(i))
                {
                    detail.Subject = nearbyAvatars[i].Subject;
                    detail.IsOperator = false;
                    detail.WasOperator = false;
                    detail.NewPosition = PositionCategory.Distant;
                    detail.OldPosition = nearbyAvatars[i].Position;
                    evt.RemovedMembers.Add(detail);

                    nearbyAvatars.Remove(i);
                }
            }

            foreach(var i in nearbyAvatars)
            {
                if (i.Key == client.Self.AgentID) { continue; }

                var newpos = CategorisePosition(i.Key, e);
                if (i.Value.Position != newpos)
                {
                    var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                    detail.Subject = nearbyAvatars[i.Key].Subject;
                    detail.IsOperator = false;
                    detail.WasOperator = false;
                    detail.NewPosition = newpos;
                    detail.OldPosition = nearbyAvatars[i.Key].Position;
                    evt.ChangedMembers.Add(detail);
                    nearbyAvatars[i.Key].Position = newpos;
                }
            }

            if (!evt.HasChanges) { return; }

            lock (syncRoot)
            {
                if (state != ChannelState.Connected)
                {
                    state = ChannelState.Connected;
                    joinTask.SetResult(true);
                }
            }

            if(this.MembersChanged != null)
            {
                MembersChanged(this, evt);
            }
        }
 public void OnMemberLeft(UUID AgentId)
 {
     if (AgentId == client.Self.AgentID) return;
     var changes = new ChannelMemberChangeEventArgs();
     var oldmember = new ChannelMemberChangeEventArgs.ChangeDetails();
     oldmember.Subject = mapper.MapUser(AgentId);
     changes.RemovedMembers.Add(oldmember);
     if (MembersChanged != null) { MembersChanged(this, changes); }
 }
        public void OnMemberJoined(UUID AgentId)
        {
            if (AgentId == client.Self.AgentID) return;
            var changes = new ChannelMemberChangeEventArgs();
            var newmember = new ChannelMemberChangeEventArgs.ChangeDetails();
            newmember.Subject = mapper.MapUser(AgentId);
            newmember.NewPosition = PositionCategory.Distant;
            newmember.OldPosition = PositionCategory.Distant;
            client.Self.GroupChatSessions.Lock(d =>
            {
                var cachedMembership = d[group.ID].FirstOrDefault(i => i.AvatarKey == AgentId);
                if (cachedMembership.AvatarKey == AgentId)
                {
                    newmember.IsOperator = cachedMembership.IsModerator;
                }
            });
            changes.NewMembers.Add(newmember);

            if (MembersChanged != null) { MembersChanged(this, changes); }
        }