Beispiel #1
0
        public void HandleNewPacket(JToken json)
        {
            if (!string.IsNullOrEmpty(LogWizard.Name))
            {
                using (var sr = json.CreateReader()) JsonSerializer.CreateDefault().Populate(sr, LogWizard);
            }

            if (PacketListWaiting.Count <= 0)
            {
                return;
            }
            foreach (var tuple in PacketListWaiting)
            {
                var h1     = json["wizard_info"]?["wizard_name"].ToString();
                var h2     = (CommandPacket)Enum.Parse(typeof(CommandPacket), json["command"].ToString());
                var header = new Tuple <string, CommandPacket>(h1, h2);
                if (!Equals(tuple, header))
                {
                    continue;
                }

                PacketListFound.Add(header, json);
                PacketListWaiting.RemoveAll(i => Equals(i, header));
                break;
            }
        }
Beispiel #2
0
        public void HandleProxy()
        {
            if (_proxyThread != null && _proxyThread.IsAlive)
            {
                _proxyProccess.Stop();
                _proxyProccess = null;
                _proxyThread.Abort();
            }

            PacketListWaiting.Clear();
            PacketListFound.Clear();

            _proxyThread = new Thread(() => {
                _proxyProccess = new Proxy {
                    IpAddress = IPAddress.Any, Port = 8080
                };
                _proxyProccess.Start();
                while (true)
                {
                    Thread.Sleep(100);
                }
            })
            {
                IsBackground = true
            };
            _proxyThread.Start();
        }