public LocalModule(LocalHandler handler)
        {
            Post("/locals/add-local", async ctx => {
                await RunWithErrorHandling <AddLocal>(ctx, async cmd =>
                {
                    await handler.Handle(cmd);

                    ctx.Response.StatusCode = (int)HttpStatusCode.Created;
                    ctx.Response.Headers.Add("Location", GetLocationHeader(ctx.Request, $"locals/{cmd.Id}"));
                });
            });

            Post("/locals/add-alias", async ctx => {
                await RunWithErrorHandling <AddLocalAlias>(ctx, async cmd =>
                {
                    await handler.Handle(cmd);

                    ctx.Response.StatusCode = (int)HttpStatusCode.Created;
                    ctx.Response.Headers.Add("Location", GetLocationHeader(ctx.Request, $"locals/{cmd.LocalId}"));
                });
            });

            Post("/locals/rename-local", ctx => RunWithErrorHandlingAndAccept <RenameLocal>(ctx, handler.Handle));

            Post("/locals/remove-local-alias", ctx => RunWithErrorHandlingAndAccept <RemoveLocalAlias>(ctx, handler.Handle));

            Post("/locals/remove-local", ctx => RunWithErrorHandlingAndAccept <RemoveLocal>(ctx, handler.Handle));
        }
Example #2
0
 /// <summary>
 /// Builds the session object with the given windowhandler
 /// </summary>
 /// <param name="wh">The reference to the bot's windowhandler</param>
 public Session(WindowHandler wh)
 {
     this.com = wh.COMMUNICATOR;
     this.kb  = wh.KEYBOARD;
     m        = wh.MOUSE;
     pm       = wh.PMOUSE;
     this.wh  = wh;
     addBook  = new AddressBook(wh);
     local    = new LocalHandler(wh);
 }
Example #3
0
        public async void ParseSource_given_no_amount_calls_ISource_without_specifying_amount()
        {
            var sourceMock = new Mock <ISource <LocalDirectory> >();
            var input      = "test";
            var mockReturn = new LocalDirectory {
                Images = new List <LocalImage> {
                    new LocalImage(), new LocalImage()
                }
            };

            sourceMock.Setup(m => m.GetContent(input)).ReturnsAsync(mockReturn);

            var handler = new LocalHandler(sourceMock.Object);
            var output  = await handler.ParseSource(input);

            Assert.Equal(2, output.Images.Count);
            sourceMock.Verify(i => i.GetContent(input), Times.Once);
        }
Example #4
0
        private ExplorerView CreateExplorer(string path = SettingsHandler.ROOT_FOLDER)
        {
            var h = new LocalHandler(path);

            h.OnError          += HandlerOnOnError;
            h.OnSetCurrentPath += HOnOnSetCurrentPath;

            var x = new ExplorerView();

            x.Init(h);

            x.SendDirectoryUpdateAsCmd += XOnSendDirectoryUpdateAsCmd;
            x.UpdateStatusBar          += XOnUpdateStatusBar;
            x.UpdatePathBarDirect      += XOnUpdatePathBarDirect;

            x.Margin = new Thickness(0, 0, 0, 0);
            return(x);
        }
Example #5
0
 /// <summary>
 /// Internal use, the Bot will initialize the script with its input handlers once its loaded into memory
 /// </summary>
 /// <param name="bot">The reference to the bot's windowhandler</param>
 public void initializeInputs(WindowHandler bot)
 {
     this.EMouse             = bot.MOUSE;
     this.EPreciseMouse      = bot.PMOUSE;
     this.EMenuHandler       = bot.MENU;
     this.ECommunicator      = bot.COMMUNICATOR;
     this.EOverViewHandler   = bot.OVERVIEW;
     this.EStationHandler    = bot.STATION;
     this.MyShip             = bot.SHIP;
     this.ESession           = bot.SESSION;
     this.ECamera            = bot.CAMERA;
     this.EKeyboard          = bot.KEYBOARD;
     this.ELocalHandler      = bot.LOCAL;
     this.EDrawingArea       = bot.DrawingArea;
     this.ELogger            = bot.LOGGER;
     this.ELogger.ScriptName = name;
     this.EAgentHandler      = bot.AGENT;
     ERandom = new Random();
 }
        public async Task TestSocketReuse()
        {
            ServerBootstrap serverBootstrap = new ServerBootstrap();
            LocalHandler    serverHandler   = new LocalHandler("SERVER");

            serverBootstrap
            .Group(new DefaultEventLoopGroup(1), new DefaultEventLoopGroup())
            .Channel <LocalServerChannel>()
            .ChildHandler(serverHandler);
            Bootstrap    clientBootstrap = new Bootstrap();
            LocalHandler clientHandler   = new LocalHandler("CLIENT");

            clientBootstrap
            .Group(new DefaultEventLoopGroup())
            .Channel <LocalChannel>()
            .RemoteAddress(new LocalAddress(LOCAL_CHANNEL)).Handler(clientHandler);

            await serverBootstrap.BindAsync(new LocalAddress(LOCAL_CHANNEL));

            int count = 100;

            for (int i = 1; i < count + 1; i++)
            {
                var ch = await clientBootstrap.ConnectAsync();

                // SPIN until we get what we are looking for.
                int target = i * c_messageCountPerRun;
                while (serverHandler.Count.Value != target || clientHandler.Count.Value != target)
                {
                    Thread.Sleep(50);
                }
                Close(ch, clientHandler);
            }

            Assert.Equal(count * 2 * c_messageCountPerRun, serverHandler.Count.Value + clientHandler.Count.Value);

            Task.WaitAll(
                serverBootstrap.Group().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5)),
                serverBootstrap.ChildGroup().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5)),
                clientBootstrap.Group().ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(5))
                );
        }
        private void Close(IChannel localChannel, LocalHandler localRegistrationHandler)
        {
            // we want to make sure we actually shutdown IN the event loop
            if (localChannel.EventLoop.InEventLoop)
            {
                // Wait until all messages are flushed before closing the channel.
                if (localRegistrationHandler.LastWriteFuture != null)
                {
                    localRegistrationHandler.LastWriteFuture.GetAwaiter().GetResult();
                }

                localChannel.CloseAsync();
                return;
            }

            localChannel.EventLoop.Execute(() => Close(localChannel, localRegistrationHandler));

            // Wait until the connection is closed or the connection attempt fails.
            localChannel.CloseCompletion.GetAwaiter().GetResult();
        }
Example #8
0
        /// <summary>
        /// Put Black.dll in the EVE process' memory
        /// </summary>
        private void inject()
        {
            if (injector != null && loaded)
            {
                try
                {
                    injector.Inject(dll, processName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.WriteLine("failed to inject");
                }


                try
                {
                    if (injector.getSyringe() != null)
                    {
                        //Thread.Sleep(15000);
                        pipename = RandomString(9);
                        pipename = "\\\\.\\pipe\\" + pipename;
                        Console.WriteLine("creating pipe " + pipename);
                        com             = new Communicator(pipename);
                        menuhandler     = new MenuHandler(this);
                        overviewhandler = new OverviewHandler(this);
                        station         = new Station(this);
                        myShip          = new Ship(this);
                        eveSession      = new Session(this);
                        cam             = new Camera(this);
                        local           = new LocalHandler(this);
                        aHandler        = new AgentHandler(this);
                        mes             = new MessageStruct()
                        {
                            Text = pipename
                        };

                        backgroundScripts = new List <Scriptable>();


                        Script.Scripts.AutoLoger autoLogger = new Script.Scripts.AutoLoger();
                        autoLogger.onStart();
                        autoLogger.initializeInputs(this);
                        backgroundScripts.Add(autoLogger);


                        Script.Scripts.InterfaceCloser icloser = new Script.Scripts.InterfaceCloser();
                        icloser.initializeInputs(this);
                        icloser.onStart();
                        backgroundScripts.Add(icloser);



                        //injector.getSyringe().CallExport(dll, "startServer");

                        injector.getSyringe().CallExport(dll, "dropServer", mes);

                        //drawingScreen.Invalidate();
                        //this.Invalidate();
                        //cw.Invalidate();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.WriteLine("Couldn't drop server");
                }
            }
        }