Exemplo n.º 1
0
        private void HandleMuteListRequest(AgentCircuit circuit, Message m)
        {
            var req = (MuteListRequest)m;

            if (req.CircuitAgentID != req.AgentID ||
                req.CircuitSessionID != req.SessionID)
            {
                return;
            }
            ViewerAgent agent = circuit.Agent;
            MuteListServiceInterface muteListService = agent.MuteListService;
            bool useCached = false;
            bool useEmpty  = true;

            if (muteListService == null)
            {
                circuit.SendMessage(new UseCachedMuteList {
                    AgentID = agent.ID
                });
                return;
            }

            string filename = $"mutes{agent.ID}";

            using (var ms = new MemoryStream())
            {
                try
                {
                    List <MuteListEntry> list = muteListService.GetList(agent.ID, req.MuteCRC);
                    byte[] data;
                    if (list.Count != 0)
                    {
                        useEmpty = false;
                        data     = list.ToBinaryData();
                    }
                    else
                    {
                        data = new byte[0];
                    }
                    if (new Crc32().Compute(data) == req.MuteCRC)
                    {
                        useCached = true;
                    }
                    else if (!useEmpty)
                    {
                        agent.AddNewFile(filename, data);
                    }
                }
                catch (UseCachedMuteListException)
                {
                    useCached = true;
                }
            }

            if (useCached)
            {
                circuit.SendMessage(new UseCachedMuteList {
                    AgentID = agent.ID
                });
            }
            else if (useEmpty)
            {
                circuit.SendMessage(new GenericMessage {
                    Method = "emptymutelist"
                });
            }
            else
            {
                circuit.SendMessage(new MuteListUpdate {
                    AgentID = agent.ID, Filename = filename
                });
            }
        }
Exemplo n.º 2
0
        public bool Run()
        {
            var muteowner  = new UUID("11111111-2222-3333-4444-112233445566");
            var mute1id    = new UUID("11223344-1122-1122-1122-112233445566");
            var mute2id    = new UUID("11223344-1122-1122-1122-112233445577");
            var mute1entry = new MuteListEntry
            {
                MuteName = "Mute1 name",
                MuteID   = mute1id,
                Type     = MuteType.ByName,
                Flags    = MuteFlags.ObjectSoundsMuted
            };
            var mute2entry = new MuteListEntry
            {
                MuteName = "Mute2 name",
                MuteID   = mute2id,
                Type     = MuteType.ByName,
                Flags    = MuteFlags.ObjectSoundsMuted
            };

            m_Log.InfoFormat("Check that mute list is empty");
            List <MuteListEntry> list = m_MuteListService.GetList(muteowner, 0);

            if (list.Count != 0)
            {
                m_Log.Error("Mute list is not empty");
                return(false);
            }

            m_MuteListService.Store(muteowner, mute1entry);

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }


            m_MuteListService.Store(muteowner, mute2entry);

            m_Log.InfoFormat("Check that mute list has 2 entries");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 2)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            bool found1 = false;
            bool found2 = false;

            foreach (MuteListEntry e in list)
            {
                if (CheckEqual(e, mute1entry, true))
                {
                    found1 = true;
                }
                if (CheckEqual(e, mute2entry, true))
                {
                    found2 = true;
                }
            }
            if (!found1 || !found2)
            {
                m_Log.Error("Mute entries content does not match");
                return(false);
            }

            m_Log.Info("Removing second entry");
            if (!m_MuteListService.Remove(muteowner, mute2entry.MuteID, mute2entry.MuteName))
            {
                m_Log.Error("Failed to remove it");
                return(false);
            }

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }

            m_Log.Info("Change mute");
            mute1entry.Flags |= MuteFlags.ParticlesNotMuted;
            m_MuteListService.Store(muteowner, mute1entry);

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }

            m_Log.Info("Removing first entry");
            if (!m_MuteListService.Remove(muteowner, mute1entry.MuteID, mute1entry.MuteName))
            {
                m_Log.Error("Failed to remove it");
                return(false);
            }

            m_Log.InfoFormat("Check that mute list is empty");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 0)
            {
                m_Log.Error("Mute list is not empty");
                return(false);
            }

            return(true);
        }