/// <summary> /// Mute an object, resident, etc. /// </summary> /// <param name="type">Mute type</param> /// <param name="id">Mute UUID</param> /// <param name="name">Mute name</param> /// <param name="flags">Mute flags</param> public void UpdateMuteListEntry(MuteType type, UUID id, string name, MuteFlags flags) { UpdateMuteListEntryPacket p = new UpdateMuteListEntryPacket(); p.AgentData.AgentID = Client.Self.AgentID; p.AgentData.SessionID = Client.Self.SessionID; p.MuteData.MuteType = (int)type; p.MuteData.MuteID = id; p.MuteData.MuteName = Utils.StringToBytes(name); p.MuteData.MuteFlags = (uint)flags; Client.Network.SendPacket(p); MuteEntry me = new MuteEntry(); me.Type = type; me.ID = id; me.Name = name; me.Flags = flags; lock (MuteList.Dictionary) { MuteList[string.Format("{0}|{1}", me.ID, me.Name)] = me; } OnMuteListUpdated(EventArgs.Empty); }
protected void MuteListUpdateHander(object sender, PacketReceivedEventArgs e) { MuteListUpdatePacket packet = (MuteListUpdatePacket)e.Packet; if (packet.MuteData.AgentID != Client.Self.AgentID) { return; } WorkPool.QueueUserWorkItem(sync => { using (AutoResetEvent gotMuteList = new AutoResetEvent(false)) { string fileName = Utils.BytesToString(packet.MuteData.Filename); string muteList = string.Empty; ulong xferID = 0; byte[] assetData = null; EventHandler<XferReceivedEventArgs> xferCallback = (object xsender, XferReceivedEventArgs xe) => { if (xe.Xfer.XferID == xferID) { assetData = xe.Xfer.AssetData; gotMuteList.Set(); } }; Client.Assets.XferReceived += xferCallback; xferID = Client.Assets.RequestAssetXfer(fileName, true, false, UUID.Zero, AssetType.Unknown, true); if (gotMuteList.WaitOne(60 * 1000, false)) { muteList = Utils.BytesToString(assetData); lock (MuteList.Dictionary) { MuteList.Dictionary.Clear(); foreach (var line in muteList.Split('\n')) { if (line.Trim() == string.Empty) continue; try { Match m; if ((m = Regex.Match(line, @"(?<MyteType>\d+)\s+(?<Key>[a-zA-Z0-9-]+)\s+(?<Name>[^|]+)|(?<Flags>.+)", RegexOptions.CultureInvariant)).Success) { MuteEntry me = new MuteEntry(); me.Type = (MuteType)int.Parse(m.Groups["MyteType"].Value); me.ID = new UUID(m.Groups["Key"].Value); me.Name = m.Groups["Name"].Value; int flags = 0; int.TryParse(m.Groups["Flags"].Value, out flags); me.Flags = (MuteFlags)flags; MuteList[string.Format("{0}|{1}", me.ID, me.Name)] = me; } else { throw new ArgumentException("Invalid mutelist entry line"); } } catch (Exception ex) { Logger.Log("Failed to parse the mute list line: " + line, Helpers.LogLevel.Warning, Client, ex); } } } OnMuteListUpdated(EventArgs.Empty); } else { Logger.Log("Timed out waiting for mute list download", Helpers.LogLevel.Warning, Client); } Client.Assets.XferReceived -= xferCallback; } }); }
public bool Equals(OpenMetaverse.MuteEntry other) { return(other != null && ID.Equals(other.ID) && Flags.Equals(other.Flags) && Name.Equals(other.Name) && Type.Equals(other.Type)); }