Inheritance: MonoBehaviour
Beispiel #1
0
        public NettyClient(string host, int port, string instanceId, Action<string, byte[]> dataReceivedAction, Action connectedAction)
        {
            this.host = host;
            this.port = port;
            this.instanceId = instanceId;
            this.dataReceivedAction = dataReceivedAction;
            this.connectedAction = connectedAction;
            this.cts = new CancellationTokenSource();

            var hostEntry = Dns.GetHostEntry(host);
            this.firstAddress = hostEntry.AddressList.First(x => x.AddressFamily == AddressFamily.InterNetwork);

            this.group = new MultithreadEventLoopGroup();

            this.bootstrap = new Bootstrap();
            this.bootstrap
                .Group(group)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                {
                    IChannelPipeline pipeline = channel.Pipeline;

                    //TODO: Send InstanceId in the pipeline instead of part of the data buffer
                    pipeline.AddLast("framing-enc", new LengthFieldPrepender(2));
                    pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(32 * 1024, 0, 2, 0, 2));

                    pipeline.AddLast("main", new NettyClientHandler(this));
                }));
        }
Beispiel #2
0
        /// <summary>
        /// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.
        /// </summary>
        /// <param name="application">Root object of the host application.</param>
        /// <param name="connectMode">Describes how the Add-in is being loaded.</param>
        /// <param name="addInInst">Object representing this Add-in.</param>
        /// <param name="custom"></param>
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            var bootstrap = new Bootstrap(_applicationObject, _addInInstance);
            bootstrap.Run();
        }
        public App()
        {
            bootstrap = new Bootstrap();
            Exit += (sender, e) => bootstrap.TryStop();
            bootstrap.Start();

            var model = new MainViewModel(new MainWindow());
            model.View.Show();
        }
Beispiel #4
0
        public void BuildsTheAppCorrectly(Bootstrap bootstrapper)
        {
            // -- Arrange

            // -- Act
            var actual = bootstrapper.ResolveCalculatorService();

            // -- Assert
            Assert.IsAssignableFrom<ICalculatorService>(actual);
        }
Beispiel #5
0
        private static Bootstrap GetBootstrap()
        {
            var bootstrap = new Bootstrap();
            bootstrap
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Group(new MultithreadEventLoopGroup());

            return bootstrap;
        }
Beispiel #6
0
        public ApiFactBase()
        {
            DatabaseHelper.ResetDatabase();

            m_httpConfiguration = new HttpConfiguration();
            var bootstrap = new Bootstrap();
            bootstrap.Initialize(m_httpConfiguration);
            m_httpServer = new HttpServer(m_httpConfiguration);
            Fixtures = new Fixtures(bootstrap.CreateLifetimeScope());
        }
Beispiel #7
0
        public async void EchoServerAndClient()
        {
            var testPromise = new TaskCompletionSource();
            var tlsCertificate = new X509Certificate2("dotnetty.com.pfx", "password");
            Func<Task> closeServerFunc = await this.StartServerAsync(true, ch =>
            {
                ch.Pipeline.AddLast("server logger", new LoggingHandler("SERVER"));
                ch.Pipeline.AddLast("server tls", TlsHandler.Server(tlsCertificate));
                ch.Pipeline.AddLast("server logger2", new LoggingHandler("SER***"));
                ch.Pipeline.AddLast("server prepender", new LengthFieldPrepender(2));
                ch.Pipeline.AddLast("server decoder", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
                ch.Pipeline.AddLast(new EchoChannelHandler());
            }, testPromise);

            var group = new MultithreadEventLoopGroup();
            Bootstrap b = new Bootstrap()
                .Group(group)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
                {
                    string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
                    var clientTlsSettings = new ClientTlsSettings(targetHost);
                    ch.Pipeline.AddLast("client logger", new LoggingHandler("CLIENT"));
                    ch.Pipeline.AddLast("client tls", new TlsHandler(stream => new SslStream(stream, true, (sender, certificate, chain, errors) => true), clientTlsSettings));
                    ch.Pipeline.AddLast("client logger2", new LoggingHandler("CLI***"));
                    ch.Pipeline.AddLast("client prepender", new LengthFieldPrepender(2));
                    ch.Pipeline.AddLast("client decoder", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
                    ch.Pipeline.AddLast(new TestScenarioRunner(this.GetEchoClientScenario, testPromise));
                }));

            this.Output.WriteLine("Configured Bootstrap: {0}", b);

            IChannel clientChannel = null;
            try
            {
                clientChannel = await b.ConnectAsync(IPAddress.Loopback, Port);

                this.Output.WriteLine("Connected channel: {0}", clientChannel);

                await Task.WhenAny(testPromise.Task, Task.Delay(TimeSpan.FromSeconds(30)));
                Assert.True(testPromise.Task.IsCompleted, "timed out");
                testPromise.Task.Wait();
            }
            finally
            {
                Task serverCloseTask = closeServerFunc();
                clientChannel?.CloseAsync().Wait(TimeSpan.FromSeconds(5));
                group.ShutdownGracefullyAsync();
                if (!serverCloseTask.Wait(ShutdownTimeout))
                {
                    this.Output.WriteLine("Didn't stop in time.");
                }
            }
        }
 protected DeviceRunner(IEventLoopGroup eventLoopGroup, string deviceKey, string iotHubConnectionString, IPEndPoint endpoint, string tlsHostName)
 {
     this.deviceKey = deviceKey;
     this.endpoint = endpoint;
     this.tlsHostName = tlsHostName;
     this.connectionStringBuilder = IotHubConnectionStringBuilder.Create(iotHubConnectionString.Contains("DeviceId=") ? iotHubConnectionString : iotHubConnectionString + ";DeviceId=abc");
     this.bootstrap = new Bootstrap()
         .Group(eventLoopGroup)
         .Channel<TcpSocketChannel>()
         .Option(ChannelOption.TcpNodelay, false);
 }
Beispiel #9
0
 public ApiFactBase(ITestOutputHelper outputHelper)
 {
     DatabaseHelper.ResetDatabase();
     //
     m_outputRedirector = new OutputRedirector(outputHelper);
     //
     m_httpConfiguration = new HttpConfiguration();
     var bootstrap = new Bootstrap();
     bootstrap.Initialize(m_httpConfiguration);
     m_httpServer = new HttpServer(m_httpConfiguration);
     Fixtures = new Fixtures(bootstrap.CreateLifetimeScope());
 }
Beispiel #10
0
        public async void EchoServerAndClient()
        {
            var testPromise = new TaskCompletionSource();
            var tlsCertificate = new X509Certificate2("dotnetty.com.pfx", "password");
            Func<Task> closeServerFunc = await this.StartServerAsync(true, ch =>
            {
                ch.Pipeline.AddLast(TlsHandler.Server(tlsCertificate));
                ch.Pipeline.AddLast(new EchoChannelHandler());
            }, testPromise);

            var group = new MultithreadEventLoopGroup();
            Bootstrap b = new Bootstrap()
                .Group(group)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
                {
                    string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
                    ch.Pipeline.AddLast(TlsHandler.Client(targetHost, null, (sender, certificate, chain, errors) => true));
                    ch.Pipeline.AddLast(new TestScenarioRunner(this.GetEchoClientScenario, testPromise));
                }));

            this.Output.WriteLine("Configured Bootstrap: {0}", b);

            IChannel clientChannel = null;
            try
            {
                clientChannel = await b.ConnectAsync(IPAddress.Loopback, Port);

                this.Output.WriteLine("Connected channel: {0}", clientChannel);

                await Task.WhenAny(testPromise.Task, Task.Delay(TimeSpan.FromMinutes(1)));
                Assert.True(testPromise.Task.IsCompleted);
                testPromise.Task.Wait();
            }
            finally
            {
                Task serverCloseTask = closeServerFunc();
                if (clientChannel != null)
                {
                    clientChannel.CloseAsync().Wait(TimeSpan.FromSeconds(5));
                }
                group.ShutdownGracefullyAsync();
                if (!serverCloseTask.Wait(ShutdownTimeout))
                {
                    this.Output.WriteLine("Didn't stop in time.");
                }
            }
        }
Beispiel #11
0
        static async Task RunClientAsync()
        {
            var eventListener = new ObservableEventListener();
            eventListener.LogToConsole();
            eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);

            var group = new MultithreadEventLoopGroup();

            X509Certificate2 cert = null;
            string targetHost = null;
            if (EchoClientSettings.IsSsl)
            {
                cert = new X509Certificate2("dotnetty.com.pfx", "password");
                targetHost = cert.GetNameInfo(X509NameType.DnsName, false);
            }
            try
            {
                var bootstrap = new Bootstrap();
                bootstrap
                    .Group(group)
                    .Channel<TcpSocketChannel>()
                    .Option(ChannelOption.TcpNodelay, true)
                    .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;

                        if (cert != null)
                        {
                            pipeline.AddLast(new TlsHandler(stream => new SslStream(stream, true, (sender, certificate, chain, errors) => true), new ClientTlsSettings(targetHost)));
                        }
                        pipeline.AddLast(new LengthFieldPrepender(2));
                        pipeline.AddLast(new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));

                        pipeline.AddLast(new EchoClientHandler());
                    }));

                IChannel bootstrapChannel = await bootstrap.ConnectAsync(new IPEndPoint(EchoClientSettings.Host, EchoClientSettings.Port));

                Console.ReadLine();

                await bootstrapChannel.CloseAsync();
            }
            finally
            {
                group.ShutdownGracefullyAsync().Wait(1000);
                eventListener.Dispose();
            }
        }
Beispiel #12
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var bootStrap = new Bootstrap();
 /*           _globalComponentManager = bootStrap.Initialize();

           _logHandler = _globalComponentManager.Container.GetExportedValue<ILogHandler>();*/

            //_logHandler = new LogHandler();
            
        }
Beispiel #13
0
        static async Task RunClientAsync()
        {
            IPAddress host = IPAddress.Parse("192.168.0.10");
            int port = 5882;

            var factory = new ClientSessionFactory();
            var group = new MultithreadEventLoopGroup();

            try
            {
                var bootstrap = new Bootstrap();
                bootstrap
                    .Group(group)
                    .Channel<TcpSocketChannel>()
                    .Option(ChannelOption.TcpNodelay, true)
                    .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;

                        pipeline.AddLast(new LengthFieldPrepender(
                            ByteOrder.LittleEndian, 2, 0, false));
                        pipeline.AddLast(new LengthFieldBasedFrameDecoder(
                            ByteOrder.LittleEndian, ushort.MaxValue, 0, 2, 0, 2, true));
                        pipeline.AddLast(new ClientHandler(factory));
                    }));

                IChannel bootstrapChannel = await bootstrap.ConnectAsync(new IPEndPoint(host, port));

                Console.ReadLine();

                await bootstrapChannel.CloseAsync();
            }
            finally
            {
                group.ShutdownGracefullyAsync().Wait(1000);
            }
        }
Beispiel #14
0
 // ReSharper disable once UnusedParameter.Local
 private static void Main(string[] args)
 {
     Bootstrap.Init();
 }
Beispiel #15
0
 public static void Main()
 {
     Bootstrap.Init();
     Load();
 }
 protected override void SetupBootstrap(Bootstrap bootstrap)
 {
     bootstrap.Group(new EventLoopGroup()).Channel <TcpChannel>();
 }
        public void SimpleSend(IByteBuffer source, bool bindClient, IByteBufferAllocator allocator, AddressFamily addressFamily, byte[] expectedData, int count)
        {
            SocketDatagramChannel serverChannel = null;
            IChannel clientChannel = null;
            var      serverGroup   = new MultithreadEventLoopGroup(1);
            var      clientGroup   = new MultithreadEventLoopGroup(1);

            try
            {
                var handler         = new TestHandler(expectedData);
                var serverBootstrap = new Bootstrap();
                serverBootstrap
                .Group(serverGroup)
                .ChannelFactory(() => new SocketDatagramChannel(addressFamily))
                .Option(ChannelOption.Allocator, allocator)
                .Option(ChannelOption.SoBroadcast, true)
                .Option(ChannelOption.IpMulticastLoopDisabled, false)
                .Handler(new ActionChannelInitializer <IChannel>(channel =>
                {
                    channel.Pipeline.AddLast(nameof(SocketDatagramChannelUnicastTest), handler);
                }));

                IPAddress address = NetUtil.GetLoopbackAddress(addressFamily);
                this.Output.WriteLine($"Unicast server binding to:({addressFamily}){address}");
                Task <IChannel> task = serverBootstrap.BindAsync(address, IPEndPoint.MinPort);

                Assert.True(task.Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds * 5)),
                            $"Unicast server binding to:({addressFamily}){address} timed out!");

                serverChannel = (SocketDatagramChannel)task.Result;
                var endPoint = (IPEndPoint)serverChannel.LocalAddress;

                var clientBootstrap = new Bootstrap();
                clientBootstrap
                .Group(clientGroup)
                .ChannelFactory(() => new SocketDatagramChannel(addressFamily))
                .Option(ChannelOption.Allocator, allocator)
                .Option(ChannelOption.SoBroadcast, true)
                .Option(ChannelOption.IpMulticastLoopDisabled, false)
                .Handler(new ActionChannelInitializer <IChannel>(channel =>
                {
                    channel.Pipeline.AddLast("Dummy", new NetUtil.DummyHandler());
                }));

                var clientEndPoint = new IPEndPoint(
                    addressFamily == AddressFamily.InterNetwork ? IPAddress.Any : IPAddress.IPv6Any,
                    IPEndPoint.MinPort);

                clientBootstrap
                .LocalAddress(clientEndPoint)
                .RemoteAddress(new IPEndPoint(address, endPoint.Port));

                if (bindClient)
                {
                    this.Output.WriteLine($"Unicast client binding to:({addressFamily}){address}");
                    task = clientBootstrap.BindAsync(clientEndPoint);

                    Assert.True(task.Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds * 5)),
                                $"Unicast client binding to:({clientEndPoint}) timed out!");
                    clientChannel = task.Result;
                }
                else
                {
                    this.Output.WriteLine($"Register client binding to:({addressFamily}){address}");
                    task = (Task <IChannel>)clientBootstrap.RegisterAsync();
                    Assert.True(task.Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds)), "Unicast client register timed out!");
                    clientChannel = task.Result;
                }

                for (int i = 0; i < count; i++)
                {
                    var packet = new DatagramPacket((IByteBuffer)source.Retain(), new IPEndPoint(address, endPoint.Port));
                    clientChannel.WriteAndFlushAsync(packet).Wait();
                    Assert.True(handler.WaitForResult());

                    var duplicatedPacket = (DatagramPacket)packet.Duplicate();
                    duplicatedPacket.Retain();
                    clientChannel.WriteAndFlushAsync(duplicatedPacket).Wait();
                    Assert.True(handler.WaitForResult());
                }
            }
            finally
            {
                serverChannel?.CloseAsync().Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds));
                clientChannel?.CloseAsync().Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds));

                source.Release();
                Task.WaitAll(
                    serverGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)),
                    clientGroup.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1)));
            }
        }
Beispiel #18
0
        public static void MalphiteOnLoadingComplete()
        {
            if (!_Player.CharacterName.Contains("Malphite"))
            {
                return;
            }
            Game.Print("Doctor's Malphite Loaded! Ported by DEATGODx", Color.Orange);
            Bootstrap.Init(null);
            Q = new Spell(SpellSlot.Q, 625);
            W = new Spell(SpellSlot.W, 250);
            E = new Spell(SpellSlot.E, 400);
            R = new Spell(SpellSlot.R, 1000);
            //, SkillShotType.Circular, 250, 700, 270);
            Thm = new Font(Drawing.Direct3DDevice, new FontDescription {
                FaceName = "Tahoma", Height = 32, Weight = FontWeight.Bold, OutputPrecision = FontPrecision.Default, Quality = FontQuality.ClearType
            });
            Thn = new Font(Drawing.Direct3DDevice, new FontDescription {
                FaceName = "Tahoma", Height = 20, Weight = FontWeight.Bold, OutputPrecision = FontPrecision.Default, Quality = FontQuality.ClearType
            });
            Ignite = new Spell(_Player.GetSpellSlot("summonerdot"), 600);
            var Menumalp = new Menu("Malphite", "Malphite", true);

            ComboMenu = new Menu("Combo Settings", "Combo");
            ComboMenu.Add(new MenuSeparator("Combo Settings", "Combo Settings"));
            ComboMenu.Add(new MenuBool("ComboQ", "Use [Q] Combo"));
            ComboMenu.Add(new MenuBool("ComboW", "Use [W] Combo"));
            ComboMenu.Add(new MenuBool("ComboE", "Use [E] Combo"));
            ComboMenu.Add(new MenuSlider("DisQ", "Use [Q] If Enemy Distance >", 10, 0, 650));
            ComboMenu.Add(new MenuSeparator("[Q] Distance < 125 = Always [Q]", "[Q] Distance < 125 = Always [Q]"));
            ComboMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            ComboMenu.Add(new MenuKeyBind("ComboFQ", "Use [R] Selected Target", System.Windows.Forms.Keys.T, KeyBindType.Press)).Permashow();
            ComboMenu.Add(new MenuBool("ComboR", "Use [R] Aoe"));
            ComboMenu.Add(new MenuSlider("MinR", "Min Hit Enemies Use [R] Aoe", 3, 1, 5));
            ComboMenu.Add(new MenuSeparator("Interrupt Settings", "Interrupt Settings"));
            ComboMenu.Add(new MenuBool("inter", "Use [R] Interrupt", false));
            Menumalp.Add(ComboMenu);
            HarassMenu = new Menu("Harass Settings", "Harass");
            HarassMenu.Add(new MenuSeparator("Harass Settings", "Harass Settings"));
            HarassMenu.Add(new MenuBool("HarassQ", "Use [Q] Harass"));
            HarassMenu.Add(new MenuBool("HarassW", "Use [W] Harass"));
            HarassMenu.Add(new MenuBool("HarassE", "Use [E] Harass"));
            HarassMenu.Add(new MenuSlider("DisQ2", "Use [Q] If Enemy Distance >", 350, 0, 650));
            HarassMenu.Add(new MenuSeparator("[Q] Distance < 125 = Always [Q]", "[Q] Distance < 125 = Always [Q]"));
            HarassMenu.Add(new MenuSlider("ManaQ", "Mana Harass", 40));
            Menumalp.Add(HarassMenu);
            JungleClearMenu = new Menu("JungleClear Settings", "JungleClear");
            JungleClearMenu.Add(new MenuSeparator("JungleClear Settings", "JungleClear Settings"));
            JungleClearMenu.Add(new MenuBool("QJungle", "Use [Q] JungleClear"));
            JungleClearMenu.Add(new MenuBool("WJungle", "Use [W] JungleClear"));
            JungleClearMenu.Add(new MenuBool("EJungle", "Use [E] JungleClear"));
            JungleClearMenu.Add(new MenuSlider("JungleMana", "Mana JungleClear", 20));
            Menumalp.Add(JungleClearMenu);
            LaneClearMenu = new Menu("LaneClear Settings", "LaneClear");
            LaneClearMenu.Add(new MenuSeparator("Lane Clear Settings", "Lane Clear Settings"));
            LaneClearMenu.Add(new MenuBool("LaneClearQ", "Use [Q] LaneClear"));
            LaneClearMenu.Add(new MenuBool("LaneClearW", "Use [W] LaneClear"));
            LaneClearMenu.Add(new MenuBool("LaneClearE", "Use [E] LaneClear"));
            LaneClearMenu.Add(new MenuSlider("ManaLC", "Mana LaneClear", 50));
            LaneClearMenu.Add(new MenuSeparator("LastHit Settings", "LastHit Settings"));
            LaneClearMenu.Add(new MenuBool("LastHitQ", "Use [Q] LastHit"));
            LaneClearMenu.Add(new MenuSlider("ManaLH", "Mana LastHit", 50));
            Menumalp.Add(LaneClearMenu);
            KillStealMenu = new Menu("KillSteal Settings", "KillSteal");
            KillStealMenu.Add(new MenuSeparator("KillSteal Settings", "KillSteal Settings"));
            KillStealMenu.Add(new MenuBool("KsQ", "Use [Q] KillSteal"));
            KillStealMenu.Add(new MenuBool("KsE", "Use [E] KillSteal"));
            KillStealMenu.Add(new MenuBool("ign", "Use [Ignite] KillSteal"));
            KillStealMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            KillStealMenu.Add(new MenuBool("KsR", "Use [R] KillSteal"));
            KillStealMenu.Add(new MenuSlider("minKsR", "Min [R] Distance KillSteal", 100, 1, 1000));
            KillStealMenu.Add(new MenuKeyBind("RKb", "[R] Semi Manual Key", System.Windows.Forms.Keys.Y, KeyBindType.Toggle)).Permashow();
            KillStealMenu.Add(new MenuSeparator("Recommended Distance 600", "Recommended Distance 600"));
            Menumalp.Add(KillStealMenu);
            Drawings = new Menu("Draw Settings", "Draw");
            Drawings.Add(new MenuSeparator("Drawing Settings", "Drawing Settings"));
            Drawings.Add(new MenuBool("DrawQ", "[Q] Range"));
            Drawings.Add(new MenuBool("DrawE", "[E] Range"));
            Drawings.Add(new MenuBool("DrawR", "[R] Range"));
            Drawings.Add(new MenuBool("DrawRhit", "[R] Draw Hit"));
            Drawings.Add(new MenuBool("Notifications", "Alerter Can Killable [R]"));
            Drawings.Add(new MenuBool("Draw_Disabled", "Disabled Drawings"));
            Menumalp.Add(Drawings);
            Menumalp.Attach();
            Drawing.OnDraw += Drawing_OnDraw;
            Game.OnUpdate  += Game_OnUpdate;
            Interrupter.OnInterrupterSpell += Interupt;
        }
        private async Task <RegistrationOperationStatus> ProvisionOverTcpCommonAsync(
            ProvisioningTransportRegisterMessage message,
            ClientTlsSettings tlsSettings,
            CancellationToken cancellationToken)
        {
            var tcs = new TaskCompletionSource <RegistrationOperationStatus>();

            Func <Stream, SslStream> streamFactory = stream => new SslStream(stream, true, RemoteCertificateValidationCallback);

            Bootstrap bootstrap = new Bootstrap()
                                  .Group(s_eventLoopGroup)
                                  .Channel <TcpSocketChannel>()
                                  .Option(ChannelOption.TcpNodelay, true)
                                  .Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
                                  .Handler(new ActionChannelInitializer <ISocketChannel>(ch =>
            {
                ch.Pipeline.AddLast(
                    new ReadTimeoutHandler(ReadTimeoutSeconds),
                    new TlsHandler(streamFactory, tlsSettings),
                    MqttEncoder.Instance,
                    new MqttDecoder(isServer: false, maxMessageSize: MaxMessageSize),
                    new LoggingHandler(LogLevel.DEBUG),
                    new ProvisioningChannelHandlerAdapter(message, tcs, cancellationToken));
            }));

            if (Logging.IsEnabled)
            {
                Logging.Associate(bootstrap, this);
            }

            IPAddress[] addresses = await Dns.GetHostAddressesAsync(message.GlobalDeviceEndpoint).ConfigureAwait(false);

            if (Logging.IsEnabled)
            {
                Logging.Info(this, $"DNS resolved {addresses.Length} addresses.");
            }

            IChannel  channel       = null;
            Exception lastException = null;

            foreach (IPAddress address in addresses)
            {
                cancellationToken.ThrowIfCancellationRequested();

                try
                {
                    if (Logging.IsEnabled)
                    {
                        Logging.Info(this, $"Connecting to {address}.");
                    }

                    channel = await bootstrap.ConnectAsync(address, Port).ConfigureAwait(false);

                    break;
                }
                catch (AggregateException ae)
                {
                    ae.Handle((ex) =>
                    {
                        if (ex is ConnectException) // We will handle DotNetty.Transport.Channels.ConnectException
                        {
                            lastException = ex;
                            if (Logging.IsEnabled)
                            {
                                Logging.Info(
                                    this,
                                    $"ConnectException trying to connect to {address}: {ex}");
                            }

                            return(true);
                        }

                        return(false); // Let anything else stop the application.
                    });
                }
            }

            if (channel == null)
            {
                string errorMessage = "Cannot connect to Provisioning Service.";
                if (Logging.IsEnabled)
                {
                    Logging.Error(this, errorMessage);
                }

                ExceptionDispatchInfo.Capture(lastException).Throw();
            }

            return(await tcs.Task.ConfigureAwait(false));
        }
        public void SetUp(BenchmarkContext context)
        {
            TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine(args.Exception);

            this.ClientGroup = new MultithreadEventLoopGroup(1);
            this.ServerGroup = new MultithreadEventLoopGroup(1);
            this.WorkerGroup = new MultithreadEventLoopGroup();

            Encoding iso = Encoding.GetEncoding("ISO-8859-1");
            this.message = iso.GetBytes("ABC");

            this.inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName);
            this.outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName);
            var counterHandler = new CounterHandlerInbound(this.inboundThroughputCounter);
            this.signal = new ManualResetEventSlimReadFinishedSignal(this.ResetEvent);

            // reserve up to 10mb of 16kb buffers on both client and server; we're only sending about 700k worth of messages
            this.serverBufferAllocator = new PooledByteBufferAllocator();
            this.clientBufferAllocator = new PooledByteBufferAllocator();

            Assembly assembly = typeof(TcpChannelPerfSpecs).Assembly;
            byte[] certificateData;
            using (Stream sourceStream = assembly.GetManifestResourceStream(assembly.GetManifestResourceNames()[0]))
            using (var tempStream = new MemoryStream())
            {
                sourceStream.CopyTo(tempStream);
                certificateData = tempStream.ToArray();
            }
            var tlsCertificate = new X509Certificate2(certificateData, "password");
            string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);

            ServerBootstrap sb = new ServerBootstrap()
                .Group(this.ServerGroup, this.WorkerGroup)
                .Channel<TcpServerSocketChannel>()
                .ChildOption(ChannelOption.Allocator, this.serverBufferAllocator)
                .ChildHandler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
                {
                    channel.Pipeline
                        //.AddLast(TlsHandler.Server(tlsCertificate))
                        .AddLast(this.GetEncoder())
                        .AddLast(this.GetDecoder())
                        .AddLast(counterHandler)
                        .AddLast(new CounterHandlerOutbound(this.outboundThroughputCounter))
                        .AddLast(new ReadFinishedHandler(this.signal, WriteCount));
                }));

            Bootstrap cb = new Bootstrap()
                .Group(this.ClientGroup)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.Allocator, this.clientBufferAllocator)
                .Handler(new ActionChannelInitializer<TcpSocketChannel>(
                    channel =>
                    {
                        channel.Pipeline
                            //.AddLast(TlsHandler.Client(targetHost, null, (sender, certificate, chain, errors) => true))
                            .AddLast(this.GetEncoder())
                            .AddLast(this.GetDecoder())
                            .AddLast(counterHandler)
                            .AddLast(new CounterHandlerOutbound(this.outboundThroughputCounter));
                    }));

            // start server
            this.serverChannel = sb.BindAsync(TEST_ADDRESS).Result;

            // connect to server
            this.clientChannel = cb.ConnectAsync(this.serverChannel.LocalAddress).Result;
        }
Beispiel #21
0
        private static async Task RunClientAsync()
        {
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            IEventLoopGroup   group             = new DispatcherEventLoopGroup();

            try
            {
                Bootstrap bootstrap = new Bootstrap()
                                      .Group(group)
                                      .Channel <TcpChannel>()
                                      .Option(ChannelOption.SoBacklog, 8192)
                                      .Handler(new ActionChannelInitializer <IChannel>(channel =>
                {
                    IChannelPipeline pipeline = channel.Pipeline;
                    pipeline.AddLast("decoder", new HttpResponseDecoder(4096, 8192, 8192, false));
                    pipeline.AddLast("aggregator", new HttpObjectAggregator(1024));
                    pipeline.AddLast("encoder", new HttpRequestEncoder());
                    pipeline.AddLast("deflater", new HttpContentDecompressor());    //解压
                    pipeline.AddLast("handler", httpClientHandler);
                }));

                Stopwatch stopwatch = new Stopwatch();
                while (true)
                {
                    Console.WriteLine("请输入请求地址(http://127.0.0.1:5000/api/values)");
                    string url = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(url))
                    {
                        url = "http://127.0.0.1:5000/api/values";
                    }

                    try
                    {
                        httpClientHandler = new HttpClientHandler();
                        Uri uri = new Uri(url);
                        stopwatch.Reset();
                        stopwatch.Start();
                        IChannel chanel = bootstrap.ConnectAsync(IPAddress.Parse(uri.Host), uri.Port).Result;

                        DefaultFullHttpRequest request = new DefaultFullHttpRequest(DotNetty.Codecs.Http.HttpVersion.Http11, HttpMethod.Get, uri.ToString());
                        HttpHeaders            headers = request.Headers;
                        headers.Set(HttpHeaderNames.Host, uri.Authority);

                        chanel.WriteAndFlushAsync(request).Wait();
                        while (true)
                        {
                            if (httpClientHandler.Data != null)
                            {
                                Console.WriteLine("结果:{0}", httpClientHandler.Data);
                                break;
                            }
                        }
                        stopwatch.Stop();
                        Console.WriteLine("耗时:{0}ms", stopwatch.ElapsedMilliseconds);
                        //await chanel.CloseAsync();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            finally
            {
                group.ShutdownGracefullyAsync().Wait();
            }
        }
        private static void Main(string[] args)
        {
            var bootstrap = new Bootstrap();

            bootstrap.Start(args);
        }
        static void DotNettyTest()
        {
            int        port       = 8007;
            ClientWait clientWait = new ClientWait();

            RunServerAsync();
            RunClientAsync();
            void RunServerAsync()
            {
                try
                {
                    var bootstrap = new ServerBootstrap()
                                    .Group(new MultithreadEventLoopGroup(1), new MultithreadEventLoopGroup(4))
                                    .Channel <TcpServerSocketChannel>()
                                    .Option(ChannelOption.SoBacklog, 100)
                                    .ChildHandler(new ActionChannelInitializer <IChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;
                        pipeline.AddLast("framing-enc", new LengthFieldPrepender(2));
                        pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));

                        pipeline.AddLast(new EchoServerHandler("小明"));
                    }));

                    IChannel boundChannel = bootstrap.BindAsync(port).Result;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            void RunClientAsync()
            {
                try
                {
                    Stopwatch watch     = new Stopwatch();
                    var       bootstrap = new Bootstrap()
                                          .Group(new MultithreadEventLoopGroup())
                                          .Channel <TcpSocketChannel>()
                                          .Option(ChannelOption.TcpNodelay, true)
                                          .Handler(new ActionChannelInitializer <ISocketChannel>(channel =>
                    {
                        IChannelPipeline pipeline = channel.Pipeline;
                        pipeline.AddLast("framing-enc", new LengthFieldPrepender(2));
                        pipeline.AddLast("framing-dec", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));

                        pipeline.AddLast(new EchoClientHandler(clientWait));
                    }));

                    watch.Start();
                    watch.Stop();
                    Console.WriteLine($"初始化耗时:{watch.ElapsedMilliseconds}ms");

                    while (true)
                    {
                        try
                        {
                            watch = new Stopwatch();
                            watch.Restart();
                            var clientChannel = bootstrap.ConnectAsync($"127.0.0.1:{port}".ToIPEndPoint()).Result;
                            clientWait.Start(clientChannel.Id.AsShortText());
                            Task.Run(() =>
                            {
                                clientWait.Wait(clientChannel.Id.AsShortText());
                                watch.Stop();
                                Console.WriteLine($"耗时:{(double)watch.ElapsedTicks / 10000}ms");
                            });
                            IByteBuffer msg = Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes($"Hello World"));
                            clientChannel.WriteAndFlushAsync(msg);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                        //Thread.Sleep(1);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            string GetTime()
            {
                return($"{(double)DateTime.Now.Ticks/10000}ms");
            }
        }
Beispiel #24
0
        // -----------------------------------------------------------------------
        // Factory Methods
        // -----------------------------------------------------------------------

        /// <summary>
        /// 
        /// </summary>
        /// <param name="bootstrap">Identifies the Service instance to which the new object will belong</param>
        /// <returns></returns>
        public static GuardCondition NewGuardCondition(Bootstrap bootstrap)
        {
            return bootstrap.GetSPI().NewGuardCondition();
        }
Beispiel #25
0
    public void OnSelectSlot(int index)
    {
        RefreshButtons();
        warning.SetActive(false);

        if (titleMetaData.slotMode == 0)  //new game
        {
            if (toggle.isOn)              //no save is ON
            {
                return;
            }

            if (stateItems[index] == null)
            {
                selectedIndex = index;
                selectedState = null;

                selectedName.text = "Empty Slot";
                selectedDate.text = itemType.text = "";

                //name new game
                nameDialog.Show(OnYes, OnNo);

                return;
            }
            else            //chose existing slot, stateitem is not null
            {
                selectedIndex = index;
                selectedState = stateItems[index];
                //confirm overwrite save
                confirmDelete.Show(selectedState, () =>
                {                //yes
                    saveSlotButtons[selectedIndex].ResetButton();
                    selectedName.text = selectedDate.text = itemType.text = "";
                    stateItems[index] = null;
                    //name deleted slot
                    nameDialog.Show(OnYes, OnNo);
                }, () =>
                {                //no
                    selectedIndex = -1;
                    selectedState = null;
                    RefreshButtons();
                });
            }
        }
        else if (titleMetaData.slotMode == 1)          //continue game
        {
            selectedIndex = index;
            selectedState = stateItems[index];

            gameName = selectedState.gameName;
            nextButton.interactable = true;
            warning.SetActive(false);
            selectedName.text = stateItems[index].gameName;
            selectedDate.text = stateItems[index].gameDate;
            itemType.text     = "This is a Standalone Scenario";

            Debug.Log("OnSelectSlot::" + index + "::" + selectedState.projectType);
            //check file version for standalone scenario
            if (selectedState.projectType == ProjectType.Standalone)
            {
                nextText.text = "Begin";
                Scenario s = Bootstrap.LoadScenarioFromFilename(selectedState.scenarioFilename);
                if (s != null)
                {
                    loadedGameScenario.text = s.scenarioName;
                    if (s.scenarioGUID != selectedState.stateGUID)
                    {
                        warningMsg.text = "WARNING\r\nThe selected item was saved with a different version of the Scenario than you have.";
                        warning.SetActive(true);
                    }
                }
                else
                {
                    loadedGameScenario.text = "";
                    selectedDate.text       = "";
                    itemType.text           = "";
                    selectedIndex           = -1;
                    selectedState           = null;
                    nextButton.interactable = false;
                    warningMsg.text         = "WARNING\r\nThere was a problem loading the Scenario this item was saved in.";
                    warning.SetActive(true);
                }
            }
            else            //campaign
            {
                nextText.text           = "Next";
                selectedDate.text       = selectedState.campaignState.gameDate;
                itemType.text           = "This is a Campaign";
                loadedGameScenario.text = selectedState.campaignState.campaign.campaignName;
                Campaign c = FileManager.LoadCampaign(selectedState.campaignState.campaign.campaignGUID.ToString());
                //check file version for campaign
                if (c.fileVersion != selectedState.fileVersion)
                {
                    warningMsg.text = "WARNING\r\nThe selected Campaign state was saved with a different version of the Campaign than you have.";
                    warning.SetActive(true);
                }
            }
        }
    }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="App"/> class.
 /// </summary>
 public App()
 {
     Bootstrap.Start <MainPage>(SetMainPage);
 }
        Func<IPAddress, int, Task<IChannel>> CreateChannelFactory(IotHubConnectionString iotHubConnectionString, MqttTransportSettings settings)
        {
            return (address, port) =>
            {
                IEventLoopGroup eventLoopGroup = EventLoopGroupPool.TakeOrAdd(this.eventLoopGroupKey);

                Func<Stream, SslStream> streamFactory = stream => new SslStream(stream, true, settings.RemoteCertificateValidationCallback);
                ClientTlsSettings clientTlsSettings;
                clientTlsSettings = settings.ClientCertificate != null ? 
                    new ClientTlsSettings(iotHubConnectionString.HostName, new List<X509Certificate> { settings.ClientCertificate }) : 
                    new ClientTlsSettings(iotHubConnectionString.HostName);
                Bootstrap bootstrap = new Bootstrap()
                    .Group(eventLoopGroup)
                    .Channel<TcpSocketChannel>()
                    .Option(ChannelOption.TcpNodelay, true)
                    .Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
                    .Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
                    {
                        var tlsHandler = new TlsHandler(streamFactory, clientTlsSettings);

                        ch.Pipeline
                            .AddLast(
                                tlsHandler, 
                                MqttEncoder.Instance, 
                                new MqttDecoder(false, 256 * 1024), 
                                this.mqttIotHubAdapterFactory.Create(this.OnConnected, this.OnMessageReceived, this.OnError, iotHubConnectionString, settings));
                    }));

                this.ScheduleCleanup(() =>
                {
                    EventLoopGroupPool.Release(this.eventLoopGroupKey);
                    return TaskConstants.Completed;
                });

                return bootstrap.ConnectAsync(address, port);
            };
        }
        public static void KogMawOnLoadingComplete()
        {
            if (!_Player.CharacterName.Contains("KogMaw"))
            {
                return;
            }
            Game.Print("Doctor's KogMaw Loaded!", Color.Orange);
            Bootstrap.Init(null);
            Q = new Spell(SpellSlot.Q, 1000);
            W = new Spell(SpellSlot.W, (uint)ObjectManager.Player.GetRealAutoAttackRange());
            E = new Spell(SpellSlot.E, 1200);
            R = new Spell(SpellSlot.R, 900 + 300 * (uint)ObjectManager.Player.Spellbook.GetSpell(SpellSlot.R).Level);
            Q.SetSkillshot(0.25f, 50f, 2000f, true, false, SkillshotType.Line);
            E.SetSkillshot(0.25f, 120f, 1400f, false, false, SkillshotType.Line);
            R.SetSkillshot(1.2f, 120f, float.MaxValue, false, false, SkillshotType.Circle);
            Botrk  = new Item(ItemId.Blade_of_the_Ruined_King, 400);
            Ignite = new Spell(ObjectManager.Player.GetSpellSlot("summonerdot"), 600);
            var MenuKog = new Menu("Doctor's KogMaw", "KogMaw", true);

            MenuKog.Add(new MenuSeparator("Ideas Haxory", "Ideas Haxory"));
            ComboMenu = new Menu("Combo Settings", "Combo");
            ComboMenu.Add(new MenuSeparator("Combo Settings", "Combo Settings"));
            ComboMenu.Add(new MenuBool("ComboQ", "Use [Q] Combo"));
            ComboMenu.Add(new MenuBool("ComboW", "Use [W] Combo"));
            ComboMenu.Add(new MenuBool("ComboE", "Use [E] Combo"));
            ComboMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            ComboMenu.Add(new MenuBool("ultiR", "Use [R] Combo"));
            ComboMenu.Add(new MenuList("RMode", "Ultimate Mode:", new[] { "Always", "HP =< 50%", "HP =< 25%" })
            {
                Index = 0
            });
            ComboMenu.Add(new MenuSlider("MinR", "Max Stacks [R] Combo", 5, 1, 10));
            ComboMenu.Add(new MenuSlider("ManaR", "Mana [R] Combo", 30));
            MenuKog.Add(ComboMenu);
            HarassMenu = new Menu("Harass Settings", "Harass");
            HarassMenu.Add(new MenuSeparator("Harass Settings", "Harass Settings"));
            HarassMenu.Add(new MenuBool("HarassQ", "Use [Q] Harass"));
            HarassMenu.Add(new MenuBool("HarassW", "Use [W] Harass"));
            HarassMenu.Add(new MenuBool("HarassE", "Use [E] Harass"));
            HarassMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            HarassMenu.Add(new MenuBool("HRR", "Use [R] Harass"));
            HarassMenu.Add(new MenuSlider("MinRHR", "Max Stacks [R] Harass", 2, 1, 10));
            HarassMenu.Add(new MenuSlider("ManaHR", "Mana Harass", 50));
            MenuKog.Add(HarassMenu);
            LaneClearMenu = new Menu("LaneClear Settings", "LaneClear");
            LaneClearMenu.Add(new MenuSeparator("Lane Clear Settings", "Lane Clear Settings"));
            LaneClearMenu.Add(new MenuBool("QLC", "Use [Q] LaneClear", false));
            LaneClearMenu.Add(new MenuBool("ELC", "Use [E] LaneClear", false));
            LaneClearMenu.Add(new MenuSlider("minE", "Min Hit Minion Use [E]", 3, 1, 6));
            LaneClearMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            LaneClearMenu.Add(new MenuBool("RLC", "Use [R] LaneClear", false));
            LaneClearMenu.Add(new MenuSlider("MinRLC", "Max Stacks [R] LaneClear", 1, 1, 10));
            LaneClearMenu.Add(new MenuSlider("ManaLC", "Mana LaneClear", 50));
            LaneClearMenu.Add(new MenuSeparator("Lasthit Settings", "Lasthit Settings"));
            LaneClearMenu.Add(new MenuBool("QLH", "Use [Q] Lasthit", false));
            LaneClearMenu.Add(new MenuSlider("ManaLH", "Mana Lasthit", 70));
            MenuKog.Add(LaneClearMenu);
            JungleClearMenu = new Menu("JungleClear Settings", "JungleClear");
            JungleClearMenu.Add(new MenuSeparator("JungleClear Settings", "JungleClear Settings"));
            JungleClearMenu.Add(new MenuBool("QJungle", "Use [Q] JungleClear"));
            JungleClearMenu.Add(new MenuBool("WJungle", "Use [W] JungleClear"));
            JungleClearMenu.Add(new MenuBool("EJungle", "Use [E] JungleClear"));
            JungleClearMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            JungleClearMenu.Add(new MenuBool("RJungle", "Use [R] JungleClear"));
            JungleClearMenu.Add(new MenuSlider("MinRJC", "Max Stacks [R] JungleClear", 1, 1, 10));
            JungleClearMenu.Add(new MenuSlider("ManaJC", "Mana JungleClear", 30));
            MenuKog.Add(JungleClearMenu);
            KillStealMenu = new Menu("KillSteal Settings", "KillSteal");
            KillStealMenu.Add(new MenuSeparator("KillSteal Settings", "KillSteal Settings"));
            KillStealMenu.Add(new MenuBool("KsQ", "Use [Q] KillSteal"));
            KillStealMenu.Add(new MenuBool("KsR", "Use [R] KillSteal"));
            KillStealMenu.Add(new MenuBool("ign", "Use [Ignite] KillSteal"));
            MenuKog.Add(KillStealMenu);
            Items = new Menu("Items Settings", "Items");
            Items.Add(new MenuSeparator("Items Settings", "Items Settings"));
            Items.Add(new MenuBool("you", "Use [Youmuu]"));
            Items.Add(new MenuBool("BOTRK", "Use [BOTRK]"));
            Items.Add(new MenuSlider("ihp", "My HP Use BOTRK <=", 50));
            Items.Add(new MenuSlider("ihpp", "Enemy HP Use BOTRK <=", 50));
            MenuKog.Add(Items);
            Misc = new Menu("Misc Settings", "Misc");
            Misc.Add(new MenuSeparator("Misc Settings", "Misc Settings"));
            Misc.Add(new MenuBool("checkSkin", "Use Skin Changer", false));
            Misc.Add(new MenuList("skin.Id", "Skin Mode", new[] { "Default", "1", "2", "3", "4", "5", "6", "7", "8" })
            {
                Index = 0
            });
            Misc.Add(new MenuBool("AntiGap", "Use [E] AntiGap"));
            Misc.Add(new MenuSeparator("Drawing Settings", "Drawing Settings"));
            Misc.Add(new MenuBool("DrawQ", "[Q] Range", false));
            Misc.Add(new MenuBool("DrawW", "[W] Range"));
            Misc.Add(new MenuBool("DrawE", "[E] Range", false));
            Misc.Add(new MenuBool("DrawR", "[R] Range"));
            MenuKog.Add(Misc);
            MenuKog.Attach();
            Drawing.OnDraw        += Drawing_OnDraw;
            Gapcloser.OnGapcloser += Gapcloser_OnGapcloser;
            Game.OnUpdate         += Game_OnUpdate;
            Orbwalker.OnAction    += ResetAttack;
        }
        private static void OnLoaded(EventArgs args)
        {
            if (Player.Instance.ChampionName != "Vladimir")
            {
                return;
            }
            Bootstrap.Init(null);
            Q = new Spell.Targeted(SpellSlot.Q, 600);
            W = new Spell.Active(SpellSlot.W);
            E = new Spell.Active(SpellSlot.E, 610);
            R = new Spell.Skillshot(SpellSlot.R, 700, SkillShotType.Circular, 250, 1200, 150);
            if (HasSpell("summonerdot"))
            {
                Ignite = new Spell.Targeted(ObjectManager.Player.GetSpellSlotFromName("summonerdot"), 600);
            }
            Zhonia = new Item((int)ItemId.Zhonyas_Hourglass);
            var flashSlot = Vlad.GetSpellSlotFromName("summonerflash");

            Flash = new Spell.Skillshot(flashSlot, 32767, SkillShotType.Linear);

            VladMenu = MainMenu.AddMenu("Bloodimir", "bloodimir");
            VladMenu.AddGroupLabel("Bloodimir.Bloodimir");
            VladMenu.AddSeparator();
            VladMenu.AddLabel("Bloodimir c what i did there? version 1.0.5.2");

            ComboMenu = VladMenu.AddSubMenu("Combo", "sbtw");
            ComboMenu.AddGroupLabel("Kombo Ayarları");
            ComboMenu.AddSeparator();
            ComboMenu.Add("usecomboq", new CheckBox("Q Kullan"));
            ComboMenu.Add("usecomboe", new CheckBox("E Kullan"));
            ComboMenu.Add("usecombor", new CheckBox("R Kullan"));
            ComboMenu.Add("useignite", new CheckBox("Tutuştur Kullan"));
            ComboMenu.AddSeparator();
            ComboMenu.Add("rslider", new Slider("R için gerekli kişi sayısı", 2, 0, 5));
            DrawMenu = VladMenu.AddSubMenu("Gösterge", "drawings");
            DrawMenu.AddGroupLabel("Gösterge");
            DrawMenu.AddSeparator();
            DrawMenu.Add("drawq", new CheckBox("Göster Q Menzil"));
            DrawMenu.Add("drawe", new CheckBox("Göster E Menzil"));
            DrawMenu.Add("drawr", new CheckBox("Göster R Menzil"));
            DrawMenu.Add("drawaa", new CheckBox("Göster AA Menzil"));

            LaneClear = VladMenu.AddSubMenu("Lane Clear", "laneclear");
            LaneClear.AddGroupLabel("Lane Clear Ayarları");
            LaneClear.Add("LCE", new CheckBox("E Kullan"));
            LaneClear.Add("LCQ", new CheckBox("Q Kullan"));

            LastHit = VladMenu.AddSubMenu("Last Hit", "lasthit");
            LastHit.AddGroupLabel("Son VURUŞ Ayarları");
            LastHit.Add("LHQ", new CheckBox("Kullan Q"));

            HarassMenu = VladMenu.AddSubMenu("Harass Menu", "harass");
            HarassMenu.AddGroupLabel("Dürtme Settings");
            HarassMenu.Add("hq", new CheckBox("Dürtme Q"));
            HarassMenu.Add("he", new CheckBox("Dürtme E"));
            HarassMenu.Add("autoh", new CheckBox("Otomatik Dürtme"));
            HarassMenu.Add("autohq", new CheckBox("Dürtmede otomatik Q Kullan"));
            HarassMenu.Add("autohe", new CheckBox("Dürtmede otomatik E Kullan"));


            MiscMenu = VladMenu.AddSubMenu("Misc Menu", "miscmenu");
            MiscMenu.AddGroupLabel("Ek");
            MiscMenu.AddSeparator();
            MiscMenu.Add("ksq", new CheckBox("KS için Q"));
            MiscMenu.Add("kse", new CheckBox("KS için E"));
            MiscMenu.Add("zhonias", new CheckBox("Zhonya Kullan"));
            MiscMenu.Add("zhealth", new Slider("Canım Şundan az ise Zhonya bas %", 8));
            MiscMenu.AddSeparator();
            MiscMenu.Add("gapcloserw", new CheckBox("Anti Gapcloser W"));
            MiscMenu.Add("gapcloserhp", new Slider("Gapcloser W Health %", 25));
            MiscMenu.AddSeparator();

            SkinMenu = VladMenu.AddSubMenu("Skin Changer", "skin");
            SkinMenu.AddGroupLabel("İstediğin Görünümü Seç");

            var skinchange = SkinMenu.Add("sID", new Slider("Skin", 5, 0, 7));
            var sid        = new[]
            { "Default", "Count", "Marquius", "Nosferatu", "Vandal", "Blood Lord", "Soulstealer", "Academy" };

            skinchange.DisplayName    = sid[skinchange.CurrentValue];
            skinchange.OnValueChange +=
                delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = sid[changeArgs.NewValue];
            };

            Game.OnUpdate         += Tick;
            Drawing.OnDraw        += OnDraw;
            Gapcloser.OnGapcloser += Gapcloser_OnGapCloser;
        }
Beispiel #30
0
        private Task<IChannel> ConnectAsync()
        {
            var bootstrap = new Bootstrap();
            bootstrap
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Group(new MultithreadEventLoopGroup())
                .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                {
                    var pipeline = channel.Pipeline;
                    pipeline.AddLast(new LengthFieldPrepender(4));
                    pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));

                    pipeline.AddLast(new MessageReceiveHandler(_serialization, _resultDictionary));
                }));
            return bootstrap.ConnectAsync(_endPoint);
        }
Beispiel #31
0
 static void Main(string[] args)
 {
     Bootstrap.Init();
     Events.OnLoad += OnLoad;
 }
Beispiel #32
0
        private static void OnLoaded(EventArgs args)
        {
            if (Player.Instance.ChampionName != "Vladimir")
            {
                return;
            }
            Bootstrap.Init(null);
            Q = new Spell.Targeted(SpellSlot.Q, 600);
            W = new Spell.Active(SpellSlot.W);
            E = new Spell.Active(SpellSlot.E, 610);
            R = new Spell.Skillshot(SpellSlot.R, 900, SkillShotType.Circular, (int)250f, (int)1200f, (int)150f);
            var summoner1 = _Player.Spellbook.GetSpell(SpellSlot.Summoner1);
            var summoner2 = _Player.Spellbook.GetSpell(SpellSlot.Summoner2);

            if (summoner1.Name == "summonerdot")
            {
                Ignite = new Spell.Targeted(SpellSlot.Summoner1, 600);
            }
            else if (summoner2.Name == "summonerdot")
            {
                Ignite = new Spell.Targeted(SpellSlot.Summoner2, 600);
            }
            VladMenu = MainMenu.AddMenu("Bloodimir", "bloodimir");
            VladMenu.AddGroupLabel("Bloodimir.Bloodimir");
            VladMenu.AddSeparator();
            VladMenu.AddLabel("Bloodimir c what i did there?");

            ComboMenu = VladMenu.AddSubMenu("Combo", "sbtw");
            ComboMenu.AddGroupLabel("Combo Settings");
            ComboMenu.AddSeparator();
            ComboMenu.Add("usecomboq", new CheckBox("Use Q"));
            ComboMenu.Add("usecomboe", new CheckBox("Use E"));
            ComboMenu.Add("usecombor", new CheckBox("Use R"));
            ComboMenu.AddSeparator();
            ComboMenu.Add("rslider", new Slider("Minimum people for R", 1, 0, 5));

            DrawMenu = VladMenu.AddSubMenu("Drawings", "drawings");
            DrawMenu.AddGroupLabel("Drawings");
            DrawMenu.AddSeparator();
            DrawMenu.Add("drawq", new CheckBox("Draw Q"));
            DrawMenu.Add("drawe", new CheckBox("Draw E"));

            LaneClear = VladMenu.AddSubMenu("Lane Clear", "laneclear");
            LaneClear.AddGroupLabel("Lane Clear Settings");
            LaneClear.Add("LCE", new CheckBox("Use E"));
            LaneClear.Add("LCQ", new CheckBox("Use Q"));

            LastHit = VladMenu.AddSubMenu("Last Hit", "lasthit");
            LastHit.AddGroupLabel("Last Hit Settings");
            LastHit.Add("LHQ", new CheckBox("Use Q"));

            MiscMenu = VladMenu.AddSubMenu("Misc Menu", "miscmenu");
            MiscMenu.AddGroupLabel("KS");
            MiscMenu.AddSeparator();
            MiscMenu.Add("ksq", new CheckBox("KS with Q"));
            MiscMenu.AddSeparator();
            MiscMenu.Add("ksignite", new CheckBox("Ks with Ignite", false));
            MiscMenu.AddSeparator();
            MiscMenu.Add("dodgew", new CheckBox("Use W to Dodge WIP"));
            MiscMenu.AddSeparator();
            MiscMenu.Add("debug", new CheckBox("Debug", false));

            SkinMenu = VladMenu.AddSubMenu("Skin Changer", "skin");
            SkinMenu.AddGroupLabel("Choose the desired skin");

            var skinchange = SkinMenu.Add("sID", new Slider("Skin", 0, 0, 7));
            var sID        = new[]
            { "Default", "Count", "Marquius", "Nosferatu", "Vandal", "Blood Lord", "Soulstealer", "Academy" };

            skinchange.DisplayName    = sID[skinchange.CurrentValue];
            skinchange.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = sID[changeArgs.NewValue];
                if (MiscMenu["debug"].Cast <CheckBox>().CurrentValue)
                {
                    Chat.Print("skin-changed");
                }
            };

            Game.OnTick    += Tick;
            Drawing.OnDraw += OnDraw;
        }
Beispiel #33
0
        public static void MasterYiOnLoadingComplete()
        {
            if (!_Player.CharacterName.Contains("MasterYi"))
            {
                return;
            }
            Game.Print("Doctor's Yi Loaded! Ported By DEATHGODX", Color.Orange);
            Bootstrap.Init(null);
            Q      = new Spell(SpellSlot.Q, 625);
            W      = new Spell(SpellSlot.W);
            E      = new Spell(SpellSlot.E);
            R      = new Spell(SpellSlot.R);
            Botrk  = new Item(ItemId.Blade_of_the_Ruined_King, 400);
            Bil    = new Item(3144, 475f);
            Youmuu = new Item(3142, 10);
            Ignite = new Spell(ObjectManager.Player.GetSpellSlot("summonerdot"), 600);
            var MenuCorki = new Menu("Doctor's Yi", "Yi", true);

            ComboMenu = new Menu("Combo Settings", "Combo");
            ComboMenu.Add(new MenuSeparator("Combo Settings", "Combo Settings"));
            ComboMenu.Add(new MenuBool("ComboQ", "Use [Q] Combo"));
            ComboMenu.Add(new MenuBool("ComboW", "Use [W] Combo"));
            ComboMenu.Add(new MenuBool("ComboE", "Use [E] Combo"));
            ComboMenu.Add(new MenuSeparator("Ultimate Settings", "Ultimate Settings"));
            ComboMenu.Add(new MenuBool("ComboR", "Use [R] Count Enemies Around"));
            ComboMenu.Add(new MenuSlider("MinR", "Min Enemies Use [R]", 2, 1, 5));
            ComboMenu.Add(new MenuSeparator("Use [W] Low HP", "Use [W] Low HP"));
            ComboMenu.Add(new MenuBool("WLowHp", "Use [W] Low Hp"));
            ComboMenu.Add(new MenuSlider("minHealth", "Use [W] My Hp <=", 25));
            ComboMenu.Add(new MenuSeparator("Use [Q] Dodge Spell", "Use [Q] Dodge Spell"));
            ComboMenu.Add(new MenuBool("dodge", "Use [Q] Dodge"));
            ComboMenu.Add(new MenuBool("antiGap", "Use [Q] Anti Gap"));
            ComboMenu.Add(new MenuSlider("delay", "Use [Q] Dodge Delay", 1, 1, 1000));
            MenuCorki.Add(ComboMenu);
            MenuCorki.Attach();
            Evade = new Menu("Spell Dodge Settings", "Evade");
            Evade.Add(new MenuSeparator("Dodge Settings", "Dodge Settings"));
            foreach (var enemies in GameObjects.EnemyHeroes.Where(a => a.Team != ObjectManager.Player.Team))
            {
                Evade.Add(new MenuSeparator(enemies.CharacterName, enemies.CharacterName));
                {
                    foreach (var spell in enemies.Spellbook.Spells.Where(a => a.Slot == SpellSlot.Q || a.Slot == SpellSlot.W || a.Slot == SpellSlot.E || a.Slot == SpellSlot.R))
                    {
                        if (spell.Slot == SpellSlot.Q)
                        {
                            Evade.Add(new MenuBool(spell.SData.Name, enemies.CharacterName + " : " + spell.Slot.ToString() + " : " + spell.Name, false));
                        }
                        else if (spell.Slot == SpellSlot.W)
                        {
                            Evade.Add(new MenuBool(spell.SData.Name, enemies.CharacterName + " : " + spell.Slot.ToString() + " : " + spell.Name, false));
                        }
                        else if (spell.Slot == SpellSlot.E)
                        {
                            Evade.Add(new MenuBool(spell.SData.Name, enemies.CharacterName + " : " + spell.Slot.ToString() + " : " + spell.Name, false));
                        }
                        else if (spell.Slot == SpellSlot.R)
                        {
                            Evade.Add(new MenuBool(spell.SData.Name, enemies.CharacterName + " : " + spell.Slot.ToString() + " : " + spell.Name, false));
                        }
                    }
                }
            }

            HarassMenu = new Menu("Harass Settings", "Harass");
            HarassMenu.Add(new MenuSeparator("Harass Settings", "Harass Settings"));
            HarassMenu.Add(new MenuBool("HarassQ", "Use [Q] Harass"));
            HarassMenu.Add(new MenuBool("HarassW", "Use [W] Harass"));
            HarassMenu.Add(new MenuBool("HarassE", "Use [E] Harass"));
            HarassMenu.Add(new MenuSlider("ManaQ", "Mana Harass", 40));
            MenuCorki.Add(HarassMenu);
            LaneClearMenu = new Menu("Clear Settings", "LaneClear");
            LaneClearMenu.Add(new MenuSeparator("Clear Settings", "Clear Settings"));
            LaneClearMenu.Add(new MenuBool("QLC", "Use [Q] LaneClear"));
            LaneClearMenu.Add(new MenuSlider("mine", "Min x Minions Killable Use Q", 3, 1, 4));
            LaneClearMenu.Add(new MenuBool("ELC", "Use [E] LaneClear"));
            LaneClearMenu.Add(new MenuSlider("ManaLC", "Mana LaneClear", 50));
            LaneClearMenu.Add(new MenuSeparator("JungleClear Settings", "JungleClear Settings"));
            LaneClearMenu.Add(new MenuBool("QJungle", "Use [Q] JungleClear"));
            LaneClearMenu.Add(new MenuBool("EJungle", "Use [E] JungleClear"));
            LaneClearMenu.Add(new MenuSlider("MnJungle", "Mana JungleClear", 30));
            MenuCorki.Add(LaneClearMenu);
            Items = new Menu("Items Settings", "Items");
            Items.Add(new MenuSeparator("Items Settings", "Items Settings"));
            Items.Add(new MenuBool("you", "Use [Youmuu]"));
            Items.Add(new MenuBool("BOTRK", "Use [Botrk]"));
            Items.Add(new MenuSlider("ihp", "My HP Use BOTRK <=", 50));
            Items.Add(new MenuSlider("ihpp", "Enemy HP Use BOTRK <=", 50));
            MenuCorki.Add(Items);
            KillStealMenu = new Menu("KillSteal Settings", "KillSteal");
            KillStealMenu.Add(new MenuSeparator("KillSteal Settings", "KillSteal Settings"));
            KillStealMenu.Add(new MenuBool("KsQ", "Use [Q] KillSteal"));
            KillStealMenu.Add(new MenuBool("ign", "Use [Ignite] KillSteal"));
            MenuCorki.Add(KillStealMenu);
            Drawings = new Menu("Draw Settings", "Draw");
            Drawings.Add(new MenuSeparator("Drawing Settings", "Drawing Settings"));
            Drawings.Add(new MenuBool("DrawQ", "[Q] Range"));
            MenuCorki.Add(Drawings);
            MenuCorki.Add(Evade);
            Drawing.OnDraw += Drawing_OnDraw;
            Game.OnUpdate  += Game_OnUpdate;
            AIBaseClient.OnProcessSpellCast += AIHeroClient_OnProcessSpellCast;
            Orbwalker.OnAction    += ResetAttack;
            Gapcloser.OnGapcloser += Gapcloser_OnGapCloser;
        }
Beispiel #34
0
        private static void Loading_OnComplete(EventArgs args)
        {
            if (Jax.Hero != Champion.Jax)
            {
                return;
            }
            Chat.Print("[Addon] [Champion] [Jax]", System.Drawing.Color.AliceBlue);

            Bootstrap.Init(null);
            SpellDataInst smite = _Player.Spellbook.Spells.Where(spell => spell.Name.Contains("smite")).Any() ? _Player.Spellbook.Spells.Where(spell => spell.Name.Contains("smite")).First() : null;

            if (smite != null)
            {
                Smite = new Spell.Targeted(smite.Slot, 500);
            }
            Healthpot        = new Item(2003, 0);
            Manapot          = new Item(2004, 0);
            RefillablePotion = new Item(2031, 0);
            HuntersPotion    = new Item(2032, 0);
            CorruptionPotion = new Item(2033, 0);
            uint level = (uint)Player.Instance.Level;

            Q = new Spell.Targeted(SpellSlot.Q, 700);
            W = new Spell.Active(SpellSlot.W);
            E = new Spell.Active(SpellSlot.E, 187);
            R = new Spell.Active(SpellSlot.R);

            Menu = MainMenu.AddMenu("Jax", "Jax");

            ComboMenu = Menu.AddSubMenu("Combo Settings", "ComboSettings");
            ComboMenu.AddLabel("Combo Settings");
            ComboMenu.Add("QCombo", new CheckBox("Use Q"));
            ComboMenu.Add("WCombo", new CheckBox("Use W"));
            ComboMenu.Add("ECombo", new CheckBox("Use E"));
            ComboMenu.Add("RCombo", new CheckBox("Use R"));
            ComboMenu.Add("useTiamat", new CheckBox("Use Items"));

            HarassMenu = Menu.AddSubMenu("Harass Settings", "HarassSettings");
            HarassMenu.AddLabel("Harass Settings");
            HarassMenu.Add("QHarass", new CheckBox("Use Q"));
            HarassMenu.Add("WHarass", new CheckBox("Use W"));
            HarassMenu.Add("EHarass", new CheckBox("Use E"));

            FarmingMenu = Menu.AddSubMenu("Lane Clear", "FarmSettings");

            FarmingMenu.AddLabel("Lane Clear");
            FarmingMenu.Add("QLaneClear", new CheckBox("Use Q LaneClear"));
            FarmingMenu.Add("QlaneclearMana", new Slider("Mana < %", 45, 0, 100));
            FarmingMenu.Add("WLaneClear", new CheckBox("Use W LaneClear"));
            FarmingMenu.Add("WlaneclearMana", new Slider("Mana < %", 35, 0, 100));
            FarmingMenu.Add("ELaneClear", new CheckBox("Use E LaneClear"));
            FarmingMenu.Add("ElaneclearMana", new Slider("Mana < %", 60, 0, 100));

            FarmingMenu.AddLabel("Jungle Clear");
            FarmingMenu.Add("QJungleClear", new CheckBox("Use Q in Jungle"));
            FarmingMenu.Add("QJungleClearMana", new Slider("Mana < %", 60, 0, 100));
            FarmingMenu.Add("WJungleClear", new CheckBox("Use W in Jungle"));
            FarmingMenu.Add("WJungleClearMana", new Slider("Mana < %", 30, 0, 100));
            FarmingMenu.Add("EJungleClear", new CheckBox("Use E in Jungle"));
            FarmingMenu.Add("EJungleClearMana", new Slider("Mana < %", 30, 0, 100));

            FarmingMenu.AddLabel("Last Hit Settings");
            FarmingMenu.Add("Qlasthit", new CheckBox("Use Q LastHit"));
            FarmingMenu.Add("Wlasthit", new CheckBox("Use W LastHit"));
            FarmingMenu.Add("QlasthitMana", new Slider("Mana < %", 35, 0, 100));


            SetSmiteSlot();
            if (SmiteSlot != SpellSlot.Unknown)
            {
                SmiteMenu = Menu.AddSubMenu("Smite Usage", "SmiteUsage");
                SmiteMenu.Add("SmiteEnemy", new CheckBox("Use Smite Combo for Enemy!"));
                SmiteMenu.AddLabel("Smite Usage");
                SmiteMenu.Add("Use Smite?", new CheckBox("Use Smite"));
                SmiteMenu.Add("Red?", new CheckBox("Red"));
                SmiteMenu.Add("Blue?", new CheckBox("Blue"));
                SmiteMenu.Add("Dragon?", new CheckBox("Dragon"));
                SmiteMenu.Add("Baron?", new CheckBox("Baron"));
            }


            MiscMenu = Menu.AddSubMenu("More Settings", "Misc");

            MiscMenu.AddLabel("Auto");
            MiscMenu.Add("Auto Ignite", new CheckBox("Auto Ignite"));
            MiscMenu.Add("autoQ", new CheckBox("Use Auto Q to Flee/Escape"));
            MiscMenu.Add("autoE", new CheckBox("Use Auto E"));
            MiscMenu.Add("autoECount", new Slider("Enemy Count ", 3, 1, 5));
            MiscMenu.AddSeparator();
            MiscMenu.AddLabel("Items");
            MiscMenu.AddSeparator();
            MiscMenu.AddLabel("BOTRK,Bilgewater Cutlass Settings");
            MiscMenu.Add("botrkHP", new Slider("My HP < %", 60, 0, 100));
            MiscMenu.Add("botrkenemyHP", new Slider("Enemy HP < %", 60, 0, 100));

            MiscMenu.AddLabel("KillSteal");
            MiscMenu.Add("Qkill", new CheckBox("Use Q KillSteal"));
            MiscMenu.Add("Ekill", new CheckBox("Use E KillSteal"));

            MiscMenu.AddLabel("Activator");
            MiscMenu.Add("useHP", new CheckBox("Use Health Potion"));
            MiscMenu.Add("useHPV", new Slider("HP < %", 45, 0, 100));
            MiscMenu.Add("useMana", new CheckBox("Use Mana Potion"));
            MiscMenu.Add("useManaV", new Slider("Mana < %", 45, 0, 100));
            MiscMenu.Add("useCrystal", new CheckBox("Use Refillable Potions"));
            MiscMenu.Add("useCrystalHPV", new Slider("HP < %", 65, 0, 100));
            MiscMenu.Add("useCrystalManaV", new Slider("Mana < %", 65, 0, 100));

            DrawMenu = Menu.AddSubMenu("Draw Settings", "Drawings");
            DrawMenu.Add("drawAA", new CheckBox("Draw AA Range"));
            DrawMenu.Add("drawQ", new CheckBox("Draw Q Range"));

            Game.OnTick    += Game_OnTick;
            Drawing.OnDraw += Drawing_OnDraw;

            Chat.Print("Perrrrrrrrrfect Addon", System.Drawing.Color.Red);
        }
Beispiel #35
0
        // ReSharper disable InconsistentNaming
        private static void Main(string[] args)
        // ReSharper restore InconsistentNaming
        {
            try
            {
                string loggingLocation = ApplicationParameters.LoggingLocation;
                //no file system at this point
                if (!Directory.Exists(loggingLocation))
                {
                    Directory.CreateDirectory(loggingLocation);
                }

                Log4NetAppenderConfiguration.configure(loggingLocation);
                Bootstrap.initialize();
                Bootstrap.startup();

                var license = LicenseValidation.validate();
                if (license.is_licensed_version())
                {
                    try
                    {
                        var licensedAssembly = Assembly.LoadFile(ApplicationParameters.LicensedAssemblyLocation);
                        license.AssemblyLoaded = true;
                        license.Assembly       = licensedAssembly;
                        license.Version        = VersionInformation.get_current_informational_version(licensedAssembly);
                        Type licensedComponent = licensedAssembly.GetType(ApplicationParameters.LicensedComponentRegistry, throwOnError: true, ignoreCase: true);
                        SimpleInjectorContainer.add_component_registry_class(licensedComponent);
                    }
                    catch (Exception ex)
                    {
                        "chocolatey".Log().Error(
                            @"Error when attempting to load chocolatey licensed assembly. Ensure
 that chocolatey.licensed.dll exists at 
 '{0}'.
 The error message itself may be helpful as well:{1} {2}".format_with(
                                ApplicationParameters.LicensedAssemblyLocation,
                                Environment.NewLine,
                                ex.Message
                                ));
                    }
                }
                var container = SimpleInjectorContainer.Container;

                add_or_remove_licensed_source(license, container);

                var config     = container.GetInstance <ChocolateyConfiguration>();
                var fileSystem = container.GetInstance <IFileSystem>();

                var warnings = new List <string>();

                ConfigurationBuilder.set_up_configuration(
                    args,
                    config,
                    container,
                    license,
                    warning => { warnings.Add(warning); }
                    );
                Config.initialize_with(config);

                report_version_and_exit_if_requested(args, config);

                trap_exit_scenarios(config);

                if (config.RegularOutput)
                {
                    "logfile".Log().Info(() => "".PadRight(60, '='));
#if DEBUG
                    "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0} v{1}{2} (DEBUG BUILD)".format_with(ApplicationParameters.Name, config.Information.ChocolateyProductVersion, license.is_licensed_version() ? " {0}".format_with(license.LicenseType) : string.Empty));
#else
                    if (config.Information.ChocolateyVersion == config.Information.ChocolateyProductVersion && args.Any())
                    {
                        "logfile".Log().Info(() => "{0} v{1}{2}".format_with(ApplicationParameters.Name, config.Information.ChocolateyProductVersion, license.is_licensed_version() ? " {0}".format_with(license.LicenseType) : string.Empty));
                    }
                    else
                    {
                        "chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0} v{1}{2}".format_with(ApplicationParameters.Name, config.Information.ChocolateyProductVersion, license.is_licensed_version() ? " {0}".format_with(license.LicenseType) : string.Empty));
                    }
#endif
                }

                if (warnings.Count != 0 && config.RegularOutput)
                {
                    foreach (var warning in warnings.or_empty_list_if_null())
                    {
                        "chocolatey".Log().Warn(ChocolateyLoggers.Important, warning);
                    }
                }

                if (config.HelpRequested)
                {
                    pause_execution_if_debug();
                    Environment.Exit(-1);
                }

                Log4NetAppenderConfiguration.set_logging_level_debug_when_debug(config.Debug, excludeLoggerName: "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
                Log4NetAppenderConfiguration.set_verbose_logger_when_verbose(config.Verbose, config.Debug, "{0}LoggingColoredConsoleAppender".format_with(ChocolateyLoggers.Verbose.to_string()));
                "chocolatey".Log().Debug(() => "{0} is running on {1} v {2}".format_with(ApplicationParameters.Name, config.Information.PlatformType, config.Information.PlatformVersion.to_string()));
                //"chocolatey".Log().Debug(() => "Command Line: {0}".format_with(Environment.CommandLine));

                remove_old_chocolatey_exe(fileSystem);

                //refactor - thank goodness this is temporary, cuz manifest resource streams are dumb
                IList <string> folders = new List <string>
                {
                    "helpers",
                    "functions",
                    "redirects",
                    "tools"
                };
                AssemblyFileExtractor.extract_all_resources_to_relative_directory(fileSystem, Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources);

                var application = new ConsoleApplication();
                application.run(args, config, container);
            }
            catch (Exception ex)
            {
                var debug = false;
                // no access to the good stuff here, need to go a bit primitive in parsing args
                foreach (var arg in args.or_empty_list_if_null())
                {
                    if (arg.Contains("debug") || arg.is_equal_to("-d") || arg.is_equal_to("/d"))
                    {
                        debug = true;
                        break;
                    }
                }

                if (debug)
                {
                    "chocolatey".Log().Error(() => "{0} had an error occur:{1}{2}".format_with(
                                                 ApplicationParameters.Name,
                                                 Environment.NewLine,
                                                 ex.ToString()));
                }
                else
                {
                    "chocolatey".Log().Error(ChocolateyLoggers.Important, () => "{0}".format_with(ex.Message));
                }

                Environment.ExitCode = 1;
            }
            finally
            {
                "chocolatey".Log().Debug(() => "Exiting with {0}".format_with(Environment.ExitCode));
#if DEBUG
                "chocolatey".Log().Info(() => "Exiting with {0}".format_with(Environment.ExitCode));
#endif
                pause_execution_if_debug();
                Bootstrap.shutdown();

                Environment.Exit(Environment.ExitCode);
            }
        }
 protected abstract void SetupBootstrap(Bootstrap bootstrap);
Beispiel #37
0
        private static void OnLoaded(EventArgs args)
        {
            if (Player.Instance.ChampionName != "Tryndamere")
            {
                return;
            }
            Bootstrap.Init(null);
            Q          = new Spell.Active(SpellSlot.Q);
            W          = new Spell.Active(SpellSlot.W, 400);
            E          = new Spell.Skillshot(SpellSlot.E, 660, SkillShotType.Linear, 250, 700, (int)92.5);
            R          = new Spell.Active(SpellSlot.R);
            Botrk      = new Item(3153, 550f);
            Bilgewater = new Item(3144, 475f);
            Hydra      = new Item(3074, 250f);
            Tiamat     = new Item(3077, 250f);
            Youmuu     = new Item(3142, 10);

            _trynMenu = MainMenu.AddMenu("BloodimirTryn", "bloodimirtry");
            _trynMenu.AddGroupLabel("Bloodimir Tryndamere");
            _trynMenu.AddSeparator();
            _trynMenu.AddLabel("Bloodimir Tryndamere V1.0.0.0");

            ComboMenu = _trynMenu.AddSubMenu("Combo", "sbtw");
            ComboMenu.AddGroupLabel("Kombo Ayaları");
            ComboMenu.AddSeparator();
            ComboMenu.Add("usecomboq", new CheckBox("Q Kullan"));
            ComboMenu.Add("usecombow", new CheckBox("W Kullan"));
            ComboMenu.Add("usecomboe", new CheckBox("E Kullan"));
            ComboMenu.Add("usecombor", new CheckBox("R Kullan"));
            ComboMenu.AddSeparator();
            ComboMenu.Add("rslider", new Slider("Can % şundan azsa  Ulti Kullan ", 20, 0, 95));
            ComboMenu.AddSeparator();
            ComboMenu.Add("qhp", new Slider("Q % HP", 25, 0, 95));


            _drawMenu = _trynMenu.AddSubMenu("Drawings", "drawings");
            _drawMenu.AddGroupLabel("Gösterge");
            _drawMenu.AddSeparator();
            _drawMenu.Add("drawe", new CheckBox("Göster E"));

            LaneJungleClear = _trynMenu.AddSubMenu("Lane Jungle Clear", "lanejungleclear");
            LaneJungleClear.AddGroupLabel("Lane Jungle Clear Settings");
            LaneJungleClear.Add("LCE", new CheckBox("Use E"));

            MiscMenu = _trynMenu.AddSubMenu("Misc Menu", "miscmenu");
            MiscMenu.AddGroupLabel("Ek");
            MiscMenu.AddSeparator();
            MiscMenu.Add("kse", new CheckBox("KS için E Kullan"));
            MiscMenu.Add("ksbotrk", new CheckBox("KS için Botrk"));
            MiscMenu.Add("kshydra", new CheckBox("KS için Hydra"));
            MiscMenu.Add("usehydra", new CheckBox("Kullan Hydra"));
            MiscMenu.Add("usetiamat", new CheckBox("Kullan Tiamat"));
            MiscMenu.Add("usebotrk", new CheckBox("Kullan Botrk"));
            MiscMenu.Add("usebilge", new CheckBox("Kullan Bilgewater"));
            MiscMenu.Add("useyoumuu", new CheckBox("Kullan Youmuu"));


            _skinMenu = _trynMenu.AddSubMenu("Skin Changer", "skin");
            _skinMenu.AddGroupLabel("İstediğiniz Görünümü Seçin");

            var skinchange = _skinMenu.Add("skinid", new Slider("Skin", 4, 0, 7));
            var skinid     = new[]
            { "Default", "Highland", "King", "Viking", "Demon Blade", "Sultan", "Warring Kingdoms", "Nightmare" };

            skinchange.DisplayName    = skinid[skinchange.CurrentValue];
            skinchange.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = skinid[changeArgs.NewValue];
                if (MiscMenu["debug"].Cast <CheckBox>().CurrentValue)
                {
                    Chat.Print("skin-changed");
                }
            };
            Game.OnUpdate  += Tick;
            Drawing.OnDraw += OnDraw;
        }
 protected override void SetupBootstrap(Bootstrap bootstrap)
 {
     bootstrap.Group(new MultithreadEventLoopGroup()).Channel <TcpSocketChannel>();
 }
        public async Task BasicFunctionalityTest()
        {
            await this.EnsureServerInitializedAsync();

            int protocolGatewayPort = this.ProtocolGatewayPort;

            string iotHubConnectionString = ConfigurationManager.AppSettings["IoTHubConnectionString"];
            IotHubConnectionStringBuilder hubConnectionStringBuilder = IotHubConnectionStringBuilder.Create(iotHubConnectionString);
            bool deviceNameProvided;
            this.deviceId = ConfigurationManager.AppSettings["End2End.DeviceName"];
            if (!string.IsNullOrEmpty(this.deviceId))
            {
                deviceNameProvided = true;
            }
            else
            {
                deviceNameProvided = false;
                this.deviceId = Guid.NewGuid().ToString("N");
            }

            RegistryManager registryManager = RegistryManager.CreateFromConnectionString(iotHubConnectionString);
            if (!deviceNameProvided)
            {
                await registryManager.AddDeviceAsync(new Device(this.deviceId));
                this.ScheduleCleanup(async () =>
                {
                    await registryManager.RemoveDeviceAsync(this.deviceId);
                    await registryManager.CloseAsync();
                });
            }

            Device device = await registryManager.GetDeviceAsync(this.deviceId);
            this.deviceSas =
                new SharedAccessSignatureBuilder
                {
                    Key = device.Authentication.SymmetricKey.PrimaryKey,
                    Target = string.Format("{0}/devices/{1}", hubConnectionStringBuilder.HostName, this.deviceId),
                    KeyName = null,
                    TimeToLive = TimeSpan.FromMinutes(20)
                }
                    .ToSignature();

            EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(iotHubConnectionString, "messages/events");
            EventHubConsumerGroup ehGroup = eventHubClient.GetDefaultConsumerGroup();

            string[] partitionIds = (await eventHubClient.GetRuntimeInformationAsync()).PartitionIds;
            EventHubReceiver[] receivers = await Task.WhenAll(partitionIds.Select(pid => ehGroup.CreateReceiverAsync(pid.Trim(), DateTime.UtcNow)));

            ServiceClient serviceClient = ServiceClient.CreateFromConnectionString(iotHubConnectionString);

            Stopwatch sw = Stopwatch.StartNew();

            var testPromise = new TaskCompletionSource();

            var group = new MultithreadEventLoopGroup();
            string targetHost = this.tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
            Bootstrap bootstrap = new Bootstrap()
                .Group(group)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Handler(new ActionChannelInitializer<ISocketChannel>(ch => ch.Pipeline.AddLast(
                    TlsHandler.Client(targetHost, null, (sender, certificate, chain, errors) => true),
                    MqttEncoder.Instance,
                    new MqttDecoder(false, 256 * 1024),
                    new TestScenarioRunner(cmf => GetClientScenario(cmf, hubConnectionStringBuilder.HostName, this.deviceId, this.deviceSas), testPromise, CommunicationTimeout, CommunicationTimeout),
                    new XUnitLoggingHandler(this.output))));
            IChannel clientChannel = await bootstrap.ConnectAsync(this.ServerAddress, protocolGatewayPort);
            this.ScheduleCleanup(async () =>
            {
                await clientChannel.CloseAsync();
                await group.ShutdownGracefullyAsync();
            });

            Task testWorkTask = Task.Run(async () =>
            {
                Tuple<EventData, string>[] ehMessages = await CollectEventHubMessagesAsync(receivers, 2);

                Tuple<EventData, string> qos0Event = Assert.Single(ehMessages.Where(x => TelemetryQoS0Content.Equals(x.Item2, StringComparison.Ordinal)));
                //Assert.Equal((string)qos0Event.Item1.Properties["level"], "verbose");
                //Assert.Equal((string)qos0Event.Item1.Properties["subject"], "n/a");

                Tuple<EventData, string> qos1Event = Assert.Single(ehMessages.Where(x => TelemetryQoS1Content.Equals(x.Item2, StringComparison.Ordinal)));

                string qosPropertyName = ConfigurationManager.AppSettings["QoSPropertyName"];

                var qos0Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS0Content));
                qos0Notification.Properties[qosPropertyName] = "0";
                qos0Notification.Properties["subTopic"] = "tips";
                await serviceClient.SendAsync(this.deviceId, qos0Notification);

                var qos1Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS1Content));
                qos1Notification.Properties["subTopic"] = "firmware-update";
                await serviceClient.SendAsync(this.deviceId, qos1Notification);

                var qos2Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS2Content));
                qos2Notification.Properties[qosPropertyName] = "2";
                qos2Notification.Properties["subTopic"] = "critical-alert";
                await serviceClient.SendAsync(this.deviceId, qos2Notification);
            });

            Task timeoutTask = Task.Run(async () =>
            {
                await Task.Delay(TestTimeout);
                throw new TimeoutException("Test has timed out.");
            });

            await TaskExtensions.WhenSome(new[]
            {
                testPromise.Task,
                testWorkTask,
                timeoutTask
            }, 2);

            this.output.WriteLine(string.Format("Core test completed in {0}", sw.Elapsed));

            // making sure that device queue is empty.
            await Task.Delay(TimeSpan.FromSeconds(3));

            DeviceClient deviceClient = DeviceClient.Create(
                hubConnectionStringBuilder.HostName,
                new DeviceAuthenticationWithRegistrySymmetricKey(this.deviceId, device.Authentication.SymmetricKey.PrimaryKey));
            Client.Message message = await deviceClient.ReceiveAsync(TimeSpan.FromSeconds(1));
            Assert.True(message == null, string.Format("Message is not null: {0}", message));
        }
Beispiel #40
0
        Func <IPAddress, int, Task <IChannel> > CreateChannelFactory(IotHubConnectionString iotHubConnectionString, MqttTransportSettings settings)
        {
#if WINDOWS_UWP
            return(async(address, port) =>
            {
                PlatformProvider.Platform = new UWPPlatform();

                var eventLoopGroup = new MultithreadEventLoopGroup();

                var streamSocket = new StreamSocket();
                await streamSocket.ConnectAsync(new HostName(iotHubConnectionString.HostName), port.ToString(), SocketProtectionLevel.PlainSocket);

                streamSocket.Control.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
                await streamSocket.UpgradeToSslAsync(SocketProtectionLevel.Tls12, new HostName(iotHubConnectionString.HostName));

                var streamSocketChannel = new StreamSocketChannel(streamSocket);

                streamSocketChannel.Pipeline.AddLast(
                    MqttEncoder.Instance,
                    new MqttDecoder(false, MaxMessageSize),
                    this.mqttIotHubAdapterFactory.Create(this, iotHubConnectionString, settings));

                streamSocketChannel.Configuration.SetOption(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default);

                await eventLoopGroup.GetNext().RegisterAsync(streamSocketChannel);

                this.ScheduleCleanup(() =>
                {
                    EventLoopGroupPool.Release(this.eventLoopGroupKey);
                    return TaskConstants.Completed;
                });

                return streamSocketChannel;
            });
#else
            return((address, port) =>
            {
                IEventLoopGroup eventLoopGroup = EventLoopGroupPool.TakeOrAdd(this.eventLoopGroupKey);

                Func <Stream, SslStream> streamFactory = stream => new SslStream(stream, true, settings.RemoteCertificateValidationCallback);
                var clientTlsSettings = settings.ClientCertificate != null ?
                                        new ClientTlsSettings(iotHubConnectionString.HostName, new List <X509Certificate> {
                    settings.ClientCertificate
                }) :
                                        new ClientTlsSettings(iotHubConnectionString.HostName);
                Bootstrap bootstrap = new Bootstrap()
                                      .Group(eventLoopGroup)
                                      .Channel <TcpSocketChannel>()
                                      .Option(ChannelOption.TcpNodelay, true)
                                      .Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
                                      .Handler(new ActionChannelInitializer <ISocketChannel>(ch =>
                {
                    var tlsHandler = new TlsHandler(streamFactory, clientTlsSettings);

                    ch.Pipeline
                    .AddLast(
                        tlsHandler,
                        MqttEncoder.Instance,
                        new MqttDecoder(false, MaxMessageSize),
                        this.mqttIotHubAdapterFactory.Create(this, iotHubConnectionString, settings));
                }));

                this.ScheduleCleanup(() =>
                {
                    EventLoopGroupPool.Release(this.eventLoopGroupKey);
                    return TaskConstants.Completed;
                });

                return bootstrap.ConnectAsync(address, port);
            });
#endif
        }
Beispiel #41
0
        static void OnLoadingComplete(EventArgs args)
        {
            if (!_Player.ChampionName.Contains("Ezreal"))
            {
                return;
            }
            Chat.Print("Ezreal7 Loaded!", Color.GreenYellow);
            Chat.Print("Please Setting Target Harass Before Playing", Color.Yellow);
            Bootstrap.Init(null);
            Q = new Spell.Skillshot(SpellSlot.Q, 1150, SkillShotType.Linear, 250, 2000, 60);
            W = new Spell.Skillshot(SpellSlot.W, 1000, SkillShotType.Linear, 250, 1550, 80);
            W.AllowedCollisionCount = int.MaxValue;
            E = new Spell.Skillshot(SpellSlot.E, 475, SkillShotType.Linear, 250, 2000, 100);
            R = new Spell.Skillshot(SpellSlot.R, 5000, SkillShotType.Linear, 1000, 2000, 160);
            R.AllowedCollisionCount = int.MaxValue;
            Botrk = new Item(ItemId.Blade_of_the_Ruined_King);
            if (_Player.GetSpellSlotFromName("summonerdot") != SpellSlot.Unknown)
            {
                Ignite = new Spell.Targeted(ObjectManager.Player.GetSpellSlotFromName("summonerdot"), 600);
            }
            Menu = MainMenu.AddMenu("Ezreal7", "Ezreal");
            Menu.AddSeparator();
            ComboMenu = Menu.AddSubMenu("Combo Settings", "Combo");
            ComboMenu.AddSeparator();
            ComboMenu.AddLabel("Combo Settings");
            ComboMenu.Add("ComboQ", new CheckBox("Spell [Q]"));
            ComboMenu.Add("ComboW", new CheckBox("Spell [W]"));
            ComboMenu.Add("item", new CheckBox("Use [BOTRK]"));
            ComboMenu.Add("ComboRange", new Slider("Q-W Distance", 900, 0, 1000));
            ComboMenu.AddSeparator();
            ComboMenu.Add("ComboR", new CheckBox("Spell [R]"));
            ComboMenu.AddSeparator();
            ComboMenu.Add("MinRangeR", new Slider("Min Range Cast [R]", 1000, 0, 5000));
            ComboMenu.AddSeparator();
            ComboMenu.Add("MaxRangeR", new Slider("Max Range Cast [R]", 3000, 0, 5000));
            ComboMenu.AddSeparator();
            ComboMenu.Add("MinR", new Slider("Min Enemies Use [R]", 2, 0, 5));

            HarassMenu = Menu.AddSubMenu("Harass Settings", "Harass");
            HarassMenu.AddLabel("Harass Settings");
            HarassMenu.Add("HarassQ", new CheckBox("Spell [Q]"));
            HarassMenu.Add("ManaQ", new Slider("Min Mana Harass [Q]", 40));
            HarassMenu.AddSeparator();
            HarassMenu.Add("HarassW", new CheckBox("Spell [W]", false));
            HarassMenu.Add("ManaW", new Slider("Min Mana Harass [W]<=", 40));
            HarassMenu.AddSeparator();
            HarassMenu.AddLabel("Harass On");
            foreach (var enemies in EntityManager.Heroes.Enemies)
            {
                HarassMenu.Add("haras" + enemies.ChampionName, new CheckBox("" + enemies.ChampionName));
            }
            Auto = Menu.AddSubMenu("Auto Harass Settings", "Auto Harass");
            Auto.AddLabel("Auto Harass Settings");
            Auto.Add("AutoQ", new CheckBox("Auto [Q]"));
            Auto.Add("AutomanaQ", new Slider("Min Mana Auto [Q]", 60));
            Auto.AddSeparator();
            Auto.Add("AutoW", new CheckBox("Auto [W]", false));
            Auto.Add("AutomanaW", new Slider("Min Mana Auto [W]", 60));
            Auto.AddSeparator();
            Auto.AddLabel("Auto Harass On");
            foreach (var enemies in EntityManager.Heroes.Enemies)
            {
                Auto.Add("harass" + enemies.ChampionName, new CheckBox("" + enemies.ChampionName));
            }

            LaneClearMenu = Menu.AddSubMenu("LaneClear Settings", "LaneClear");
            LaneClearMenu.AddLabel("LastHit Settings");
            LaneClearMenu.Add("LastQ", new CheckBox("Always [Q] LastHit"));
            LaneClearMenu.Add("LhMana", new Slider("Min Mana Lasthit [Q]", 60));
            LaneClearMenu.AddSeparator();
            LaneClearMenu.Add("LhAA", new CheckBox("Only [Q] LastHit If Out Range AA", false));
            LaneClearMenu.Add("AAMana", new Slider("Min Mana Lasthit [Q] If Out Range AA", 50));
            LaneClearMenu.AddSeparator();
            LaneClearMenu.AddLabel("Lane Clear Settings");
            LaneClearMenu.Add("LastQLC", new CheckBox("Always LastHit With [Q]", false));
            LaneClearMenu.Add("ManaLC", new Slider("Min Mana LaneClear With [Q]", 70));
            LaneClearMenu.AddSeparator();
            LaneClearMenu.Add("LastAA", new CheckBox("Only [Q] LastHit If Out Range AA"));
            LaneClearMenu.Add("ManaLA", new Slider("Min Mana LastHit [Q] If Out Range AA", 50));

            JungleClearMenu = Menu.AddSubMenu("JungleClear Settings", "JungleClear");
            JungleClearMenu.AddLabel("JungleClear Settings");
            JungleClearMenu.Add("QJungle", new CheckBox("Spell [Q]"));
            JungleClearMenu.Add("MnJungle", new Slider("Min Mana JungleClear [Q]", 30));

            Misc = Menu.AddSubMenu("Misc Settings", "Misc");
            Misc.AddLabel("AntiGap Settings");
            Misc.Add("AntiGap", new CheckBox("Use [E] AntiGapcloser"));
            Misc.AddSeparator();
            Misc.AddLabel("Ultimate On CC Settings");
            Misc.Add("Rstun", new CheckBox("Use [R] If Enemy Has CC"));
            Misc.Add("MinR", new Slider("Min Range Use [R]", 800, 300, 2000));
            Misc.Add("MaxR", new Slider("Max Range Use [R]", 2200, 300, 30000));
            Misc.AddSeparator();
            Misc.AddLabel("Auto Stacks Settings");
            Misc.Add("Stack", new CheckBox("Auto Stacks In Shop"));

            KillStealMenu = Menu.AddSubMenu("KillSteal Settings", "KillSteal");
            KillStealMenu.AddLabel("KillSteal Settings");
            KillStealMenu.Add("KsQ", new CheckBox("Use [Q] KillSteal"));
            KillStealMenu.Add("KsW", new CheckBox("Use [W] KillSteal"));
            KillStealMenu.Add("ign", new CheckBox("Use [Ignite] KillSteal"));
            KillStealMenu.AddSeparator();
            KillStealMenu.AddLabel("Ultimate Settings");
            KillStealMenu.Add("KsR", new CheckBox("Use [R] KillSteal"));
            KillStealMenu.Add("minKsR", new Slider("Min [R] Range KillSteal", 900, 1, 5000));
            KillStealMenu.Add("maxKsR", new Slider("Max [R] Range KillSteal", 4000, 1, 5000));

            Skin = Menu.AddSubMenu("Skin Changer", "SkinChanger");
            Skin.Add("checkSkin", new CheckBox("Use Skin Changer"));
            Skin.Add("skin.Id", new ComboBox("Skin Mode", 8, "Default", "1", "2", "3", "4", "5", "6", "7", "8"));

            Drawings = Menu.AddSubMenu("Draw Settings", "Draw");
            Drawings.AddGroupLabel("Drawing Settings");
            Drawings.Add("DrawQ", new CheckBox("Q Range"));
            Drawings.Add("DrawW", new CheckBox("W Range", false));
            Drawings.Add("DrawE", new CheckBox("E Range", false));

            Drawing.OnDraw              += Drawing_OnDraw;
            Game.OnTick                 += Game_OnTick;
            Gapcloser.OnGapcloser       += Gapcloser_OnGapcloser;
            Obj_AI_Turret.OnBasicAttack += Obj_AI_Turret_OnBasicAttack2;
        }
Beispiel #42
0
    public Boolean Init(ConnectionListener<string> listener, IPEndPoint localEndPoint, string certFile, string certPassword, bool fLoadWholeChain)
    {
      if (channel == null)
      {
        this._listener = listener;
        bootstrap = new Bootstrap();
        loopGroup = new MultithreadEventLoopGroup(workerThreads);
        bootstrap.Group(loopGroup);

        bootstrap.Channel<SocketDatagramChannel>();

        UDPClient currClient = this;
        bootstrap.Handler(new ActionChannelInitializer<SocketDatagramChannel>(channel =>
        {
          IChannelPipeline pipeline = channel.Pipeline;
          if (isSecured)
          {
            Pkcs12Store keystore = null;
            if (certificate != null && certificate.Length > 0)
              keystore = CertificatesHelper.loadBC(certificate, certificatePassword);

            AsyncDtlsClient client = new MyAsyncDtlsClient(certFile, certPassword, fLoadWholeChain);
            _clientProtocol = new AsyncDtlsClientProtocol(client, new SecureRandom(), channel, currClient, true, ProtocolVersion.DTLSv12);
            pipeline.AddLast(new DtlsClientHandler(_clientProtocol, this));
          }


          pipeline.AddLast("handler", new RawMessageHandler(listener));
#if false
          pipeline.AddLast(new CoapEncoder(channel));
          pipeline.AddLast(new ExceptionHandler());
#endif
        }));

        bootstrap.RemoteAddress(address);

#if true

        try
        {
          Task<IChannel> task;
          if (localEndPoint != null)
          {
             task = bootstrap.BindAsync(localEndPoint);
          }
          else
          {
            task = bootstrap.BindAsync(IPEndPoint.MinPort);
          }

          task.GetAwaiter().OnCompleted(() =>
          {
            try
            {
              channel = task.Result;
              Task connectTask = channel.ConnectAsync(address);
              
              
              connectTask.GetAwaiter().OnCompleted(() =>
              {
                if (_clientProtocol == null)
                {
                  if (channel != null)
                    listener.Connected();
                  else
                    listener.ConnectFailed();
                }
                else
                {
                  startHandhshakeTimer();
                  _clientProtocol.InitHandshake(null);
                }
              });
            }
            catch (Exception)
            {
              listener.ConnectFailed();
              return;
            }
          });
        }
        catch (Exception)
        {
          return false;
        }
      }
#endif
      return true;
    }
        internal MqttTransportHandler(IotHubConnectionString iotHubConnectionString, MqttTransportSettings settings)
        {
            this.DefaultReceiveTimeout = DefaultReceiveTimeoutInSeconds;
            this.connectCompletion = new TaskCompletionSource();
            this.mqttIotHubAdapterFactory = new MqttIotHubAdapterFactory(settings);
            this.messageQueue = new ConcurrentQueue<Message>();
            this.completionQueue = new Queue<string>();
            this.serverAddress = Dns.GetHostEntry(iotHubConnectionString.HostName).AddressList[0];
            var group = new SingleInstanceEventLoopGroup();
            this.qos = settings.PublishToServerQoS;

            this.bootstrap = new Bootstrap()
                .Group(@group)
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
                {
                    ch.Pipeline.AddLast(
                        TlsHandler.Client(iotHubConnectionString.HostName, null),
                        MqttEncoder.Instance,
                        new MqttDecoder(false, 256 * 1024),
                        this.mqttIotHubAdapterFactory.Create(
                            this.OnConnected,
                            this.OnMessageReceived,
                            this.OnError, 
                            iotHubConnectionString, 
                            settings));
                }));

            this.ScheduleCleanup(async () =>
            {
                this.connectCompletion.TrySetCanceled();
                await group.ShutdownGracefullyAsync();
            });

        }
Beispiel #44
0
        public async Task BasicFunctionalityTest()
        {
            await this.EnsureServerInitializedAsync();

            int protocolGatewayPort = this.ProtocolGatewayPort;

            string iotHubConnectionString = ConfigurationManager.AppSettings["IoTHubConnectionString"];
            IotHubConnectionStringBuilder hubConnectionStringBuilder = IotHubConnectionStringBuilder.Create(iotHubConnectionString);
            bool deviceNameProvided;

            this.deviceId = ConfigurationManager.AppSettings["End2End.DeviceName"];
            if (!string.IsNullOrEmpty(this.deviceId))
            {
                deviceNameProvided = true;
            }
            else
            {
                deviceNameProvided = false;
                this.deviceId      = Guid.NewGuid().ToString("N");
            }

            RegistryManager registryManager = RegistryManager.CreateFromConnectionString(iotHubConnectionString);

            if (!deviceNameProvided)
            {
                await registryManager.AddDeviceAsync(new Device(this.deviceId));

                this.ScheduleCleanup(async() =>
                {
                    await registryManager.RemoveDeviceAsync(this.deviceId);
                    await registryManager.CloseAsync();
                });
            }

            Device device = await registryManager.GetDeviceAsync(this.deviceId);

            this.deviceSas =
                new SharedAccessSignatureBuilder
            {
                Key        = device.Authentication.SymmetricKey.PrimaryKey,
                Target     = $"{hubConnectionStringBuilder.HostName}/devices/{this.deviceId}",
                KeyName    = null,
                TimeToLive = TimeSpan.FromMinutes(20)
            }
            .ToSignature();

            EventHubClient        eventHubClient = EventHubClient.CreateFromConnectionString(iotHubConnectionString, "messages/events");
            EventHubConsumerGroup ehGroup        = eventHubClient.GetDefaultConsumerGroup();

            string[]           partitionIds = (await eventHubClient.GetRuntimeInformationAsync()).PartitionIds;
            EventHubReceiver[] receivers    = await Task.WhenAll(partitionIds.Select(pid => ehGroup.CreateReceiverAsync(pid.Trim(), DateTime.UtcNow)));

            ServiceClient serviceClient = ServiceClient.CreateFromConnectionString(iotHubConnectionString);

            Stopwatch sw = Stopwatch.StartNew();

            var clientScenarios = new ClientScenarios(hubConnectionStringBuilder.HostName, this.deviceId, this.deviceSas);

            var    group      = new MultithreadEventLoopGroup();
            string targetHost = this.tlsCertificate.GetNameInfo(X509NameType.DnsName, false);

            var       testPart1Promise = new TaskCompletionSource();
            Bootstrap bootstrap        = new Bootstrap()
                                         .Group(group)
                                         .Channel <TcpSocketChannel>()
                                         .Option(ChannelOption.TcpNodelay, true)
                                         .Handler(this.ComposeClientChannelInitializer(targetHost, clientScenarios.GetPart1Steps, testPart1Promise));
            IChannel clientChannel = await bootstrap.ConnectAsync(this.ServerAddress, protocolGatewayPort);

            this.ScheduleCleanup(() => clientChannel.CloseAsync());

            Task testWorkTask = Task.Run(async() =>
            {
                Tuple <EventData, string>[] ehMessages = await CollectEventHubMessagesAsync(receivers, 2);
                Tuple <EventData, string> qos0Event    = Assert.Single(ehMessages.Where(x => TelemetryQoS0Content.Equals(x.Item2, StringComparison.Ordinal)));
                Tuple <EventData, string> qos1Event    = Assert.Single(ehMessages.Where(x => TelemetryQoS1Content.Equals(x.Item2, StringComparison.Ordinal)));

                string qosPropertyName = ConfigurationManager.AppSettings["QoSPropertyName"];

                var qos0Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS0Content));
                qos0Notification.Properties[qosPropertyName] = "0";
                qos0Notification.Properties["subTopic"]      = "tips";
                await serviceClient.SendAsync(this.deviceId, qos0Notification);

                var qos1Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS1Content));
                qos1Notification.Properties["subTopic"] = "firmware-update";
                await serviceClient.SendAsync(this.deviceId, qos1Notification);

                var qos2Notification = new Message(Encoding.UTF8.GetBytes(NotificationQoS2Content));
                qos2Notification.Properties[qosPropertyName] = "2";
                qos2Notification.Properties["subTopic"]      = "critical-alert";
                await serviceClient.SendAsync(this.deviceId, qos2Notification);

                var qos2Notification2 = new Message(Encoding.UTF8.GetBytes(NotificationQoS2Content2));
                qos2Notification2.Properties[qosPropertyName] = "2";
                await serviceClient.SendAsync(this.deviceId, qos2Notification2);
            });

            await Task.WhenAll(testPart1Promise.Task, testWorkTask).WithTimeout(TestTimeout);

            this.output.WriteLine($"part 1 completed in {sw.Elapsed}");
            await this.EnsureDeviceQueueLengthAsync(hubConnectionStringBuilder.HostName, device, 1);

            this.output.WriteLine($"part 1 clean completed in {sw.Elapsed}");

            string part2Payload = Guid.NewGuid().ToString("N");
            await serviceClient.SendAsync(this.deviceId, new Message(Encoding.ASCII.GetBytes(part2Payload)));

            var      testPart2Promise   = new TaskCompletionSource();
            IChannel clientChannelPart2 = await bootstrap
                                          .Handler(this.ComposeClientChannelInitializer(targetHost, func => clientScenarios.GetPart2Steps(func, part2Payload), testPart2Promise))
                                          .ConnectAsync(this.ServerAddress, protocolGatewayPort);

            this.ScheduleCleanup(async() =>
            {
                await clientChannelPart2.CloseAsync();
                await group.ShutdownGracefullyAsync();
            });

            await testPart2Promise.Task.WithTimeout(TestTimeout);

            this.output.WriteLine($"Core test completed in {sw.Elapsed}");

            await this.EnsureDeviceQueueLengthAsync(hubConnectionStringBuilder.HostName, device, 0);
        }
Beispiel #45
0
        static void Main(string[] args)
        {
            var bootstrap = new Bootstrap();

            _serviceProvider = bootstrap.RegisterServices(_serviceProvider);

            var logger = _serviceProvider.GetService <ILoggerFactory>().AddConsole().CreateLogger <Program>();

            var cardGameService = _serviceProvider.GetService <IGameService>();
            var game            = cardGameService.StartGame();

            logger.LogInformation("Tearthstone başlıyor.");
            var boardService  = _serviceProvider.GetService <IBoardService>();
            var playerService = _serviceProvider.GetService <IPlayerService>();

            while (game.PlayingPlayer.Health > 0 && game.WaitingPlayer.Health > 0)
            {
                boardService.PreparePlayer(game.PlayingPlayer);

                // state
                Console.WriteLine("*************************" + game.PlayingPlayer.Name + "*************************");
                logger.LogInformation("Tur: " + (game.PlayingPlayer.TurnNumber + game.WaitingPlayer.TurnNumber));
                logger.LogInformation(game.PlayingPlayer.Name + " oyuncusunun can değeri: " + game.PlayingPlayer.Health);
                logger.LogInformation(game.WaitingPlayer.Name + " oyuncusunun can değeri: " + game.WaitingPlayer.Health);
                // draw card
                logger.LogInformation(game.PlayingPlayer.Name + " kart çekiyor.");
                boardService.DrawCard(game);
                logger.LogInformation("Kalan kart sayınız: " + game.Board.PlayingPlayerRemaining.Count);
                // is dead? playing player
                if (game.PlayingPlayer.Health <= 0)
                {
                    logger.LogInformation(game.PlayingPlayer.Name + " kart çekerken canı kalmadığından ötürü oyunu kaybetti. Öldüğü can değeri: " + game.PlayingPlayer.Health);
                    logger.LogInformation(game.WaitingPlayer.Name + " kazandı.Kazandığı can değeri: " + game.WaitingPlayer.Health + ". Tebrikler...");
                    break;
                }

                var isEnd = false;
                while (!isEnd)
                {
                    // show hand cards
                    logger.LogWarning("Kullanilabilir Mana: " + game.PlayingPlayer.Mana);
                    logger.LogInformation("Kartlarınız aşağıdaki gibidir.");
                    for (var i = 0; i < game.PlayingPlayer.Hand.Count; i++)
                    {
                        var card = game.PlayingPlayer.Hand[i];
                        logger.LogWarning("KartNo: " + i + "| Mana:" + card.ManaCost + " | " + card.Title + " | " + card.Body);
                    }

                    logger.LogInformation("Aşağıdaki durumlardan birini seçiniz.");
                    logger.LogInformation("0: Bir kart oyna");
                    logger.LogInformation("1: Turu bitir");

                    int  consoleValue     = -1;
                    bool isAvailableValue = false;
                    while (!isAvailableValue)
                    {
                        var val = Console.ReadLine();
                        isAvailableValue = int.TryParse(val, out consoleValue);
                        if (!isAvailableValue)
                        {
                            logger.LogInformation("Yanlış bir değer girdiniz. Lütfen tekrar giriniz.");
                        }
                        else if (isAvailableValue && !(consoleValue == 0 || consoleValue == 1))
                        {
                            isAvailableValue = false;
                            logger.LogInformation("Yanlış bir değer girdiniz. Lütfen tekrar giriniz.");
                        }
                    }

                    // end turn
                    if (consoleValue == 1)
                    {
                        isEnd = true;
                        var tempPlayer = game.PlayingPlayer;
                        game.PlayingPlayer = game.WaitingPlayer;
                        game.WaitingPlayer = tempPlayer;
                        Console.WriteLine("*********************************************************");
                        Console.WriteLine();
                    }
                    // play card
                    else
                    {
                        logger.LogInformation("Lütfen kart seçebilmek için yukarıdaki kartların başındaki numaralardan birini yazınız.");
                        int selectedCardIndex = -1;
                        isAvailableValue = false;
                        while (!isAvailableValue)
                        {
                            var val = Console.ReadLine();
                            isAvailableValue = int.TryParse(val, out selectedCardIndex);
                            if (!isAvailableValue)
                            {
                                logger.LogInformation("Yanlış bir değer girdiniz. Lütfen tekrar giriniz.");
                            }
                            else if (isAvailableValue && selectedCardIndex > game.PlayingPlayer.Hand.Count - 1)
                            {
                                isAvailableValue = false;
                                logger.LogInformation("Yanlış bir değer girdiniz. Lütfen tekrar giriniz.");
                            }
                        }
                        playerService.PlayCard(selectedCardIndex, game);
                        // is dead? waiting player
                        if (game.WaitingPlayer.Health <= 0)
                        {
                            logger.LogInformation(game.WaitingPlayer.Name + ", " + game.PlayingPlayer.Name + " tarafıdnan " + game.PlayingPlayer.Used[game.PlayingPlayer.Used.Count - 1].Title + " kartı ile öldürüldü. Öldüğü can değeri: " + game.WaitingPlayer.Health);
                            logger.LogInformation(game.PlayingPlayer.Name + " kazandı. Kazandığı can değeri: " + game.PlayingPlayer.Health + ". Tebrikler...");
                            break;
                        }
                    }
                }
            }

            logger.LogInformation("Oyun sonlandırıldı. Tearthstone oynadığınız için teşekkürler. Oyunu kapatmak için bir tuşa basın.");
            bootstrap.DisposeServices(_serviceProvider);
            Console.ReadKey();
        }
Beispiel #46
0
 /// <summary>
 /// Get the QoS policy ID for the given QoS policy class.
 /// </summary>
 /// <param name="policyClass"></param>
 /// <param name="bootstrap">Identifies the Service instance to which the object will belong</param>
 /// <returns></returns>
 public static QosPolicyId GetId(System.Type policyClass, Bootstrap bootstrap)
 {
     return bootstrap.GetSPI().GetQosPolicyId(policyClass);
 }
 private static void InitializeContainer(Container container)
 {
     Bootstrap.RegisterServices(container);
 }
Beispiel #48
0
 public TransportClientFactory(ISerializer<byte[]> serializer, ILogger<TransportClientFactory> logger)
 {
     _serializer = serializer;
     _logger = logger;
     _bootstrap = GetBootstrap();
 }
Beispiel #49
0
 public void GenerateID()
 {
     data.id = Bootstrap.GenerateUniqueID();
 }
 internal SingleChannelPool(Bootstrap bootstrap, IChannelPoolHandler handler)
     : base(bootstrap, handler)
 {
 }
Beispiel #51
0
        private async Task<IChannel> ConnectAsync()
        {
            if (_logger.IsEnabled(LogLevel.Information))
                _logger.Information($"准备连接到服务器:{_endPoint}。");

            var bootstrap = new Bootstrap();
            bootstrap
                .Channel<TcpSocketChannel>()
                .Option(ChannelOption.TcpNodelay, true)
                .Group(new MultithreadEventLoopGroup())
                .Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
                {
                    var pipeline = channel.Pipeline;
                    pipeline.AddLast(new LengthFieldPrepender(4));
                    pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));

                    pipeline.AddLast(new MessageReceiveHandler(_serialization, _resultDictionary, _logger));
                }));
            var result = await bootstrap.ConnectAsync(_endPoint);

            if (_logger.IsEnabled(LogLevel.Information))
                _logger.Information($"连接到服务器:{_endPoint},成功。");

            return result;
        }
Beispiel #52
0
 private static void Main()
 {
     bootstrap = new Bootstrap();
 }
Beispiel #53
0
        static void Game_OnStart(EventArgs args)
        {
            if (ChampionName != Player.Instance.BaseSkinName)
            {
                return;
            }

            Game.OnUpdate += Game_OnUpdate;

            /*Drawing.OnDraw += Game_OnDraw;
             * Obj_AI_Base.OnBuffGain += Common.OnBuffGain;
             * Gapcloser.OnGapcloser += Common.Gapcloser_OnGapCloser;
             * Game.OnTick += Common.ItemUsage;
             * SkinBase = Player.Instance.SkinId;*/
            try
            {
                Q = new Spell.Skillshot(SpellSlot.Q, 1150, SkillShotType.Linear, 250, 2000, 60);
                Q.AllowedCollisionCount = 0;
                W = new Spell.Skillshot(SpellSlot.W, 1000, SkillShotType.Linear, 250, 1600, 80);
                W.AllowedCollisionCount = int.MaxValue;
                E = new Spell.Skillshot(SpellSlot.E, 475, SkillShotType.Linear);
                E.AllowedCollisionCount = int.MaxValue;
                R = new Spell.Skillshot(SpellSlot.R, 3000, SkillShotType.Linear, 1000, 2000, 160);
                R.AllowedCollisionCount = int.MaxValue;

                Bootstrap.Init(null);
                Chat.Print("GuTenTak Addon Loading Success", Color.Green);

                Menu = MainMenu.AddMenu("GuTenTak Ezreal", "Ezreal");
                Menu.AddSeparator();
                Menu.AddLabel("GuTenTak Ezreal Addon");

                //var Enemies = EntityManager.Heroes.Enemies.Where(a => !a.IsMe).OrderBy(a => a.BaseSkinName);
                ModesMenu1 = Menu.AddSubMenu("Menu", "Modes1Ezreal");
                ModesMenu1.AddSeparator();
                ModesMenu1.AddLabel("Combo Configs");
                ModesMenu1.Add("ComboQ", new CheckBox("Use Q on Combo", true));
                ModesMenu1.Add("ComboA", new CheckBox("Use AA => Q Combo", false));
                ModesMenu1.Add("ComboW", new CheckBox("Use W on Combo", true));
                ModesMenu1.Add("ComboR", new CheckBox("Use R on Combo", true));
                ModesMenu1.Add("ManaCW", new Slider("Use W Mana %", 30));
                ModesMenu1.Add("RCount", new Slider("Cast R if Will Hit >=", 3, 2, 5));
                ModesMenu1.AddSeparator();
                ModesMenu1.AddSeparator();
                ModesMenu1.AddLabel("AutoHarass Configs");
                ModesMenu1.Add("AutoHarass", new CheckBox("Use Q on AutoHarass", false));

                ModesMenu1.Add("ManaAuto", new Slider("Mana %", 80));
                ModesMenu1.AddLabel("Harass Configs");
                ModesMenu1.Add("HarassQ", new CheckBox("Use Q on Harass", true));
                ModesMenu1.Add("ManaHQ", new Slider("Mana %", 40));
                ModesMenu1.Add("HarassW", new CheckBox("Use W on Harass", true));
                ModesMenu1.Add("ManaHW", new Slider("Mana %", 60));
                ModesMenu1.AddSeparator();
                ModesMenu1.AddLabel("Kill Steal Configs");
                ModesMenu1.Add("KS", new CheckBox("Use KillSteal", true));
                ModesMenu1.Add("KQ", new CheckBox("Use Q on KillSteal", true));
                ModesMenu1.Add("KW", new CheckBox("Use W on KillSteal", true));
                ModesMenu1.Add("KR", new CheckBox("Use R on KillSteal", true));

                ModesMenu2 = Menu.AddSubMenu("Farm", "Modes2Ezreal");
                ModesMenu2.AddLabel("LastHit Configs");
                ModesMenu2.Add("ManaF", new Slider("Mana %", 60));
                ModesMenu2.Add("LastQ", new CheckBox("Use Q on LastHit", true));
                ModesMenu2.AddLabel("Lane Clear Config");
                ModesMenu2.Add("ManaL", new Slider("Mana %", 40));
                ModesMenu2.Add("FarmQ", new CheckBox("Use Q on LaneClear", true));
                ModesMenu2.AddLabel("Jungle Clear Config");
                ModesMenu2.Add("ManaJ", new Slider("Mana %", 40));
                ModesMenu2.Add("JungleQ", new CheckBox("Use Q on JungleClear", true));

                ModesMenu3 = Menu.AddSubMenu("Misc", "Modes3Ezreal");
                ModesMenu3.AddLabel("Misc Configs");
                ModesMenu3.Add("AntiGap", new CheckBox("Use E for Anti-Gapcloser", true));
                ModesMenu3.Add("StackTear", new CheckBox("Auto stack tear in fountain", true));
                ModesMenu3.AddLabel("Flee Configs");
                ModesMenu3.Add("FleeQ", new CheckBox("Use Q on Flee", true));
                ModesMenu3.Add("FleeOQ", new CheckBox("Use Q only hero", true));
                ModesMenu3.Add("FleeE", new CheckBox("Use E on Flee", true));
                //ModesMenu3.Add("BlockE", new CheckBox("Block EnemyUnderTurret", false));
                ModesMenu3.Add("ManaFlQ", new Slider("Q Mana %", 35));

                ModesMenu3.AddLabel("Item Usage on Combo");
                ModesMenu3.Add("useItems", new CheckBox("Use Items", true));
                ModesMenu3.AddSeparator(1);
                ModesMenu3.Add("useYoumuu", new CheckBox("Use Youmuu", true));
                ModesMenu3.Add("usehextech", new CheckBox("Use Hextech", true));
                ModesMenu3.Add("useBotrk", new CheckBox("Use Botrk & Cutlass", true));
                ModesMenu3.Add("minHPBotrk", new Slider("Min health to use Botrk %", 80));
                ModesMenu3.Add("enemyMinHPBotrk", new Slider("Min enemy health to use Botrk %", 80));

                ModesMenu3.AddLabel("QSS Configs");
                ModesMenu3.Add("useQss", new CheckBox("Use QuickSilver", true));
                ModesMenu3.AddSeparator(1);
                ModesMenu3.Add("Qssmode", new ComboBox(" ", 0, "Auto", "Combo"));
                ModesMenu3.Add("Stun", new CheckBox("Stun", true));
                ModesMenu3.Add("Blind", new CheckBox("Blind", true));
                ModesMenu3.Add("Charm", new CheckBox("Charm", true));
                ModesMenu3.Add("Suppression", new CheckBox("Suppression", true));
                ModesMenu3.Add("Polymorph", new CheckBox("Polymorph", true));
                ModesMenu3.Add("Fear", new CheckBox("Fear", true));
                ModesMenu3.Add("Taunt", new CheckBox("Taunt", true));
                ModesMenu3.Add("Silence", new CheckBox("Silence", false));
                ModesMenu3.Add("QssDelay", new Slider("Use QSS Delay(ms)", 250, 0, 1000));

                ModesMenu3.AddLabel("QSS Ult Configs");
                ModesMenu3.Add("ZedUlt", new CheckBox("Zed R", true));
                ModesMenu3.Add("VladUlt", new CheckBox("Vladimir R", true));
                ModesMenu3.Add("FizzUlt", new CheckBox("Fizz R", true));
                ModesMenu3.Add("MordUlt", new CheckBox("Mordekaiser R", true));
                ModesMenu3.Add("PoppyUlt", new CheckBox("Poppy R", true));
                ModesMenu3.Add("QssUltDelay", new Slider("Use QSS Delay(ms) for Ult", 250, 0, 1000));

                ModesMenu3.AddLabel("Skin Hack");
                ModesMenu3.Add("skinhack", new CheckBox("Activate Skin hack", false));
                ModesMenu3.Add("skinId", new ComboBox("Skin Mode", 0, "Default", "1", "2", "3", "4", "5", "6", "7", "8"));

                DrawMenu = Menu.AddSubMenu("Draws", "DrawEzreal");
                DrawMenu.Add("usedraw", new CheckBox("Enable Drawings", true));
                DrawMenu.AddSeparator(1);
                DrawMenu.Add("drawQ", new CheckBox(" Draw Q", true));
                DrawMenu.Add("drawW", new CheckBox(" Draw W", true));
                DrawMenu.Add("drawR", new CheckBox(" Draw R", false));
                DrawMenu.Add("drawXR", new CheckBox(" Draw Don't Use R", true));
                DrawMenu.Add("drawXFleeQ", new CheckBox(" Draw Don't Use Flee Q", false));

                if (ModesMenu3["useQss"].Cast <CheckBox>().CurrentValue)
                {
                    Obj_AI_Base.OnBuffGain += Common.OnBuffGain;
                }
                ModesMenu3["useQss"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Obj_AI_Base.OnBuffGain += Common.OnBuffGain;
                    }
                    else
                    {
                        Obj_AI_Base.OnBuffGain -= Common.OnBuffGain;
                    }
                };

                if (ModesMenu3["useItems"].Cast <CheckBox>().CurrentValue)
                {
                    Game.OnTick += Common.ItemUsage;
                }
                ModesMenu3["useItems"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Game.OnTick += Common.ItemUsage;
                    }
                    else
                    {
                        Game.OnTick -= Common.ItemUsage;
                    }
                };

                if (DrawMenu["usedraw"].Cast <CheckBox>().CurrentValue)
                {
                    Drawing.OnDraw += Game_OnDraw;
                }
                DrawMenu["usedraw"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Drawing.OnDraw += Game_OnDraw;
                    }
                    else
                    {
                        Drawing.OnDraw -= Game_OnDraw;
                    }
                };

                if (ModesMenu3["AntiGap"].Cast <CheckBox>().CurrentValue)
                {
                    Gapcloser.OnGapcloser += Common.Gapcloser_OnGapCloser;
                }
                ModesMenu3["AntiGap"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Gapcloser.OnGapcloser += Common.Gapcloser_OnGapCloser;
                    }
                    else
                    {
                        Gapcloser.OnGapcloser -= Common.Gapcloser_OnGapCloser;
                    }
                };

                if (ModesMenu1["KS"].Cast <CheckBox>().CurrentValue)
                {
                    Game.OnTick += Common.KillSteal;
                }
                ModesMenu1["KS"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Game.OnTick += Common.KillSteal;
                    }
                    else
                    {
                        Game.OnTick -= Common.KillSteal;
                    }
                };

                if (ModesMenu1["ComboA"].Cast <CheckBox>().CurrentValue)
                {
                    Orbwalker.OnPostAttack += Common.Orbwalker_OnPostAttack;
                }
                ModesMenu1["ComboA"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Orbwalker.OnPostAttack += Common.Orbwalker_OnPostAttack;
                    }
                    else
                    {
                        Orbwalker.OnPostAttack -= Common.Orbwalker_OnPostAttack;
                    }
                };

                if (ModesMenu3["StackTear"].Cast <CheckBox>().CurrentValue)
                {
                    Game.OnTick += Common.StackTear;
                }
                ModesMenu3["StackTear"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Game.OnTick += Common.StackTear;
                    }
                    else
                    {
                        Game.OnTick -= Common.StackTear;
                    }
                };

                if (ModesMenu3["skinhack"].Cast <CheckBox>().CurrentValue)
                {
                    Player.SetSkinId(ModesMenu3["skinId"].Cast <ComboBox>().CurrentValue);
                }
                ModesMenu3["skinId"].Cast <ComboBox>().OnValueChange += (sender, vargs) =>
                {
                    if (ModesMenu3["skinhack"].Cast <CheckBox>().CurrentValue)
                    {
                        Player.SetSkinId(vargs.NewValue);
                    }
                };
                ModesMenu3["skinhack"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Player.SetSkinId(ModesMenu3["skinId"].Cast <ComboBox>().CurrentValue);
                    }
                    else
                    {
                        Player.SetSkinId(0);
                    }
                };

                if (ModesMenu1["AutoHarass"].Cast <CheckBox>().CurrentValue)
                {
                    Game.OnTick += Common.AutoQ;
                }
                ModesMenu1["AutoHarass"].Cast <CheckBox>().OnValueChange += (sender, vargs) =>
                {
                    if (vargs.NewValue)
                    {
                        Game.OnTick += Common.AutoQ;
                    }
                    else
                    {
                        Game.OnTick -= Common.AutoQ;
                    }
                };
            }

            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }