private void listen_forLinkset(string eMessage, UUID sourceId)
        {
            if (eMessage.StartsWith("INV-"))
            {
                return;
            }
            if (eMessage.StartsWith("MYKEY"))
            {
                return;
            }
            if (eMessage.Contains(":"))
            {
                return;
            }
            if (eMessage.Contains("zimfo"))
            {
                return;
            }
            lock (PrimWaitingLinkset)
            {
                LinkSetBuffer linkSetBuffer;
                if (!PrimWaitingLinkset.TryGetValue(sourceId, out linkSetBuffer))
                {
                    linkSetBuffer = new LinkSetBuffer
                                        {S = "", O = GetSimObjectFromUUID(sourceId), F = Path.Combine(dumpDir, sourceId.ToString())};
                    PrimWaitingLinkset.Add(sourceId, linkSetBuffer);
                }
                if (linkSetBuffer.S == "")
                {
                    if (!eMessage.StartsWith("Y,") || eMessage.StartsWith("\u2127"))
                    {
                        lock (PrimWaitingLinkset)
                        {
                            PrimWaitingLinkset.Remove(sourceId);
                        }
                        return;
                        throw new InvalidOperationException("wrong message came first " + linkSetBuffer + " was " + eMessage);
                    }
                }
                else
                {
                    if (eMessage.StartsWith("Y,"))
                    {
                        lock (PrimWaitingLinkset)
                        {
                            PrimWaitingLinkset.Remove(sourceId);
                        }
                        return;
                        throw new InvalidOperationException("new message came to " + linkSetBuffer + " was " + eMessage);
                    }
                }
                string soS = linkSetBuffer.S;
                if (string.IsNullOrEmpty(soS))
                {
                    linkSetBuffer.S = eMessage;
                }
                else
                {
                    linkSetBuffer.S = soS + "," + eMessage;
                }
                if (eMessage.EndsWith(",Z"))
                {

                    var mustHave = linkSetBuffer.S.Substring(2);
                    if (mustHave.StartsWith("1,"))
                    {
                        lock (fileWriterLock) File.WriteAllText(linkSetBuffer.F + ".link", "");
                        return;
                    }
                    // get past count
                    int fc = mustHave.IndexOf(',');
                    mustHave = mustHave.Substring(fc + 1);
                    // remove off ,Z
                    mustHave = mustHave.Substring(0, mustHave.Length - 2);
                    var childs = GetUUIDs(mustHave);
                    foreach (UUID list in childs)
                    {
                        if (GetSimObjectFromUUID(list) == null)
                        {
                            throw new InvalidOperationException("new message came to " + linkSetBuffer + " was " + eMessage);
                        }
                    }
                    lock (fileWriterLock) File.WriteAllText(linkSetBuffer.F + ".link", mustHave);
                    lock (PrimWaitingLinkset)
                    {
                        PrimWaitingLinkset.Remove(sourceId);
                    }
                }
            }
        }
Beispiel #2
0
        private void listen_forLinkset(string eMessage, UUID sourceId)
        {
            if (eMessage.StartsWith("INV-"))
            {
                return;
            }
            if (eMessage.StartsWith("MYKEY"))
            {
                return;
            }
            if (eMessage.Contains(":"))
            {
                return;
            }
            if (eMessage.Contains("zimfo"))
            {
                return;
            }
            lock (PrimWaitingLinkset)
            {
                LinkSetBuffer linkSetBuffer;
                if (!PrimWaitingLinkset.TryGetValue(sourceId, out linkSetBuffer))
                {
                    linkSetBuffer = new LinkSetBuffer
                    {
                        S = "", O = GetSimObjectFromUUID(sourceId), F = Path.Combine(dumpDir, sourceId.ToString())
                    };
                    PrimWaitingLinkset.Add(sourceId, linkSetBuffer);
                }
                if (linkSetBuffer.S == "")
                {
                    if (!eMessage.StartsWith("Y,") || eMessage.StartsWith("\u2127"))
                    {
                        lock (PrimWaitingLinkset)
                        {
                            PrimWaitingLinkset.Remove(sourceId);
                        }
                        return;

                        throw new InvalidOperationException("wrong message came first " + linkSetBuffer + " was " + eMessage);
                    }
                }
                else
                {
                    if (eMessage.StartsWith("Y,"))
                    {
                        lock (PrimWaitingLinkset)
                        {
                            PrimWaitingLinkset.Remove(sourceId);
                        }
                        return;

                        throw new InvalidOperationException("new message came to " + linkSetBuffer + " was " + eMessage);
                    }
                }
                string soS = linkSetBuffer.S;
                if (string.IsNullOrEmpty(soS))
                {
                    linkSetBuffer.S = eMessage;
                }
                else
                {
                    linkSetBuffer.S = soS + "," + eMessage;
                }
                if (eMessage.EndsWith(",Z"))
                {
                    var mustHave = linkSetBuffer.S.Substring(2);
                    if (mustHave.StartsWith("1,"))
                    {
                        lock (fileWriterLock) File.WriteAllText(linkSetBuffer.F + ".link", "");
                        return;
                    }
                    // get past count
                    int fc = mustHave.IndexOf(',');
                    mustHave = mustHave.Substring(fc + 1);
                    // remove off ,Z
                    mustHave = mustHave.Substring(0, mustHave.Length - 2);
                    var childs = GetUUIDs(mustHave);
                    foreach (UUID list in childs)
                    {
                        if (GetSimObjectFromUUID(list) == null)
                        {
                            throw new InvalidOperationException("new message came to " + linkSetBuffer + " was " + eMessage);
                        }
                    }
                    lock (fileWriterLock) File.WriteAllText(linkSetBuffer.F + ".link", mustHave);
                    lock (PrimWaitingLinkset)
                    {
                        PrimWaitingLinkset.Remove(sourceId);
                    }
                }
            }
        }