public static void Subscribe() { m_Active = true; using (var ctx = ZContext.Create()) { using (var socket = new ZSocket(ctx, ZSocketType.SUB)) { socket.SubscribeAll(); socket.Connect(m_Adress); while (m_Active) { ZFrame frame = socket.ReceiveFrame(); var decompressedFileStream = new MemoryStream(); if (frame != null) { using (var ms = new MemoryStream()) { frame.CopyTo(ms); ms.Position = 0; using (var stream = new ZlibStream(ms, CompressionMode.Decompress)) using (var sr = new StreamReader(stream)) { string msg = sr.ReadToEnd(); if (msg.Contains("FSDJump") || !msg.Contains("government_None")) { Response.Enqueue(msg); Debug.Print("Recieved one valid message"); } } } } Thread.Sleep(100); } } } }