/// <summary>
 /// Initializes a new instance of the <see cref="CloseConnectionFinalCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The IPC client.</param>
 /// <param name="connectionId">The FTP connection ID.</param>
 public CloseConnectionFinalCommandHandler(
     IpcServiceClient <IFtpServerHost> client,
     string connectionId)
 {
     _client = client;
     Name    = connectionId;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModuleCommandInfo"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 /// <param name="moduleName">The name of the module.</param>
 public ModuleCommandInfo(
     IpcServiceClient <IFtpServerHost> client,
     string moduleName)
 {
     _client = client;
     Name    = moduleName;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StopCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 /// <param name="status">The shell status.</param>
 public StopCommandHandler(
     [NotNull] IpcServiceClient <Api.IFtpServerHost> client,
     [NotNull] IShellStatus status)
 {
     _client = client;
     _status = status;
 }
Ejemplo n.º 4
0
 public MachineApplication(ICheckTargetRepository repository, IProgramLog <ILogger> programLog, IExceptionLog <ILogger> errorLog, IpcServiceClient <ICheckTargetServiceContract> client)
 {
     Repository  = repository;
     _programLog = programLog;
     _errorLog   = errorLog;
     _client     = client;
 }
Ejemplo n.º 5
0
 public ToolConfigutaionApplication(ICheckConfigRepository repository, IProgramLog <ILogger> programLog, IExceptionLog <ILogger> errorLog, IpcServiceClient <ICheckConfigServiceContract> client)
 {
     Repository  = repository;
     _programLog = programLog;
     _client     = client;
     _errorLog   = errorLog;
 }
Ejemplo n.º 6
0
 public AlexGuiDebuggerInteraction()
 {
     _ipcServiceClient = new IpcServiceClientBuilder <IGuiDebuggerService>()
                         .UseNamedPipe(GuiDebuggerConstants.NamedPipeName)
                         .UseTcp(IPAddress.Loopback, GuiDebuggerConstants.TcpEndpointPort)
                         .Build();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 /// <param name="status">The status of the shell.</param>
 public ShowCommandHandler(
     IpcServiceClient <IFtpServerHost> client,
     IShellStatus status)
 {
     SubCommands = status.ExtendedModuleInfoName
                   .Select(x => new ModuleCommandInfo(client, x))
                   .ToList();
 }
Ejemplo n.º 8
0
 public void testConnection_by_IP__OK()
 {
     System.Net.IPAddress serverIP = IPAddress.Parse("192.168.0.234");
     _client = new IpcServiceClientBuilder <IRoomManager>()
               .UseTcp(serverIP, 45684)
               .Build();
     Assert.IsNotNull(_client);
 }
Ejemplo n.º 9
0
 public static void Order <TInterface>(
     this IpcServiceClient <TInterface> client,
     Expression <Func <TInterface, Order> > action) where TInterface : class
 {
     AsyncContext.Run(async() =>
     {
         await client.OrderAsync(action);
     });
 }
Ejemplo n.º 10
0
        private ProcessIsolator(IsolationOptions options)
        {
            m_options = options ?? throw new ArgumentNullException(nameof(options));
            m_options.SanitizeAndSetReadOnly();

            Id         = Interlocked.Increment(ref s_nextId);
            m_pipeName = "pihost." + Id + "." + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
            m_client   = new IpcServiceClientBuilder <IHostProcess>().UseNamedPipe(m_pipeName).Build();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloseCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The IPC client.</param>
 public CloseCommandHandler(
     IpcServiceClient <IFtpServerHost> client)
 {
     _subCommands = new ICommandInfo[]
     {
         new CloseConnectionCommandHandler(client),
     }
     .ToAsyncEnumerable();
 }
Ejemplo n.º 12
0
        public AlexPipeService()
        {
            _ipcServiceClient = new IpcServiceClientBuilder <IGuiDebuggerService>()
                                .UseNamedPipe(GuiDebuggerConstants.NamedPipeName)
                                .UseTcp(IPAddress.Loopback, GuiDebuggerConstants.TcpEndpointPort)
                                .Build();


            GuiDebuggerService = new GuiDebuggerServiceProxy(_ipcServiceClient);
        }
Ejemplo n.º 13
0
        public static async Task OrderAsync <TInterface>(
            this IpcServiceClient <TInterface> client,
            Expression <Func <TInterface, Order> > action) where TInterface : class
        {
            var result = await client.InvokeAsync(action);

            if (!result.Success)
            {
                throw new InvalidOperationException(result.UserErrorMessage);
            }
        }
Ejemplo n.º 14
0
        private void ConnectToServer()
        {
            _client = new IpcServiceClientBuilder <IRoomManager>()
                      .UseNamedPipe("pipeName")
                      .Build();

/*            System.Net.IPAddress serverIP = IPAddress.Parse("192.168.0.248");
 *          _client = new IpcServiceClientBuilder<IRoomManager>()
 *              .UseTcp(serverIP, 45684)
 *              .Build();
 */         //            192.168.0.248
        }
Ejemplo n.º 15
0
        public static TResult Order <TInterface, TResult>(
            this IpcServiceClient <TInterface> client,
            Expression <Func <TInterface, Order <TResult> > > action) where TInterface : class
        {
            TResult result = default;

            AsyncContext.Run(async() =>
            {
                result = await client.OrderAsync(action);
            });
            return(result);
        }
Ejemplo n.º 16
0
        public void setUp()
        {
            _client = new IpcServiceClientBuilder <IRoomManager>()
                      .UseNamedPipe("pipeName")
                      .Build();
            System.Net.IPAddress serverIP = IPAddress.Parse("192.168.0.234");

            /*          _client = new IpcServiceClientBuilder<IRoomManager>()
             *            .UseTcp(serverIP, 45684)
             *            .Build();
             *        Assert.IsNotNull(_client);
             */}
Ejemplo n.º 17
0
        public static async Task InvokeWithDelayAsync <TInterface>(this IpcServiceClient <TInterface> client,
                                                                   Expression <Func <TInterface, Task> > exp,
                                                                   TimeSpan delay,
                                                                   CancellationToken cancellationToken = default(CancellationToken))
            where TInterface : class
        {
            var task = client.InvokeAsync(exp, cancellationToken);

            if (await Task.WhenAny(task, Task.Delay(delay, cancellationToken)) != task)
            {
                throw new TimeoutException();
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 /// <param name="status">The status of the shell.</param>
 public ShowCommandHandler(
     IpcServiceClient <IFtpServerHost> client,
     IShellStatus status)
 {
     _subCommands = status.ExtendedModuleInfoName
                    .Select(x => new ModuleCommandInfo(client, x))
                    .Concat(
         new ICommandInfo[]
     {
         new ShowConnectionsCommandInfo(client),
     })
                    .ToList()
                    .ToAsyncEnumerable();
 }
Ejemplo n.º 19
0
        public MainWindow()
        {
            InitializeComponent();

            Loaded += (sender, args) =>
            {
                try
                {
                    client = new IpcServiceClientBuilder <IFilesSyncService>()
                             .UseNamedPipe("KL2_FilesSyncService") // or .UseTcp(IPAddress.Loopback, 45684) to invoke using TCP
                             .Build();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            };
        }
        public async void LoginMethod()
        {
            if (!string.IsNullOrEmpty(Username))
            {
                LoginVisibility    = Visibility.Collapsed;
                ChatViewVisibility = Visibility.Visible;

                client = new IpcServiceClientBuilder <IChatService>()
                         .UseTcp(IPAddress.Loopback, 8000)
                         .Build();

                await client.InvokeAsync(x => x.Join(Username));

                var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick    += new EventHandler(RefreshMethod);
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
                dispatcherTimer.Start();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContinueCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 public ContinueCommandHandler(IpcServiceClient <Api.IFtpServerHost> client)
 {
     _client = client;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowConnectionsCommandInfo"/> class.
 /// </summary>
 /// <param name="client">The IPC client.</param>
 public ShowConnectionsCommandInfo(IpcServiceClient <IFtpServerHost> client)
 {
     _client = client;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloseConnectionCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The IPC client.</param>
 public CloseConnectionCommandHandler(IpcServiceClient <IFtpServerHost> client)
 {
     _client = client;
 }
Ejemplo n.º 24
0
 public IpcPipeDuplex(IpcDuplexParameters <TServer> parameters)
 {
     _parameters = parameters;
     Server      = BuildHost();
     Client      = BuildClient();
 }
Ejemplo n.º 25
0
 public void tearDown()
 {
     _client = null;
 }
Ejemplo n.º 26
0
 static async Task GoAsync(IpcServiceClient <IBmsService> client)
 {
     var result = await client.InvokeAsync(x => x.AddFloat(1.23f, 4.56f));
 }
Ejemplo n.º 27
0
        public HostProcessClient(IpcServiceClient <IHostProcess> client, string pipeName, IsolationOptions options)
        {
            m_client  = client;
            PipeName  = pipeName;
            m_process = new Process();

            var arguments = new StringBuilder();

            if (!options.StartWithExeLauncher)
            {
                HostBinary          = Path.GetFileName(s_locations.Value.HostAssemblyPath);
                m_process.StartInfo = new ProcessStartInfo(s_locations.Value.DotNetExecutablePath);
                arguments.Append(s_locations.Value.HostAssemblyPath);
            }
            else
            {
                HostBinary          = Path.GetFileName(s_locations.Value.HostExecutablePath);
                m_process.StartInfo = new ProcessStartInfo(s_locations.Value.HostExecutablePath);
            }

            if (options.CreateJobObject)
            {
                CreateJobObject = true;
                JobName         = PipeName; // For now, simply reuse pipe name
                m_jobObject     = new JobObject(JobName);

                if (options.DieOnCrash)
                {
                    // Normally, we don't want the controlling process to die when a host process
                    // crashes/exits. However, the user might want to bind their faiths together
                    // for easier management.
                    m_jobObject.AddProcess(Process.GetCurrentProcess());
                }
            }

            if (options.Limits != null && options.Limits.IsAnyEnabled)
            {
                if (options.Limits.MaxCpuUsage > 0)
                {
                    arguments.Append(" --max-cpu ").Append(options.Limits.MaxCpuUsage
                                                           .ToString(CultureInfo.InvariantCulture));
                }

                if (options.Limits.MaxMemory > 0)
                {
                    arguments.Append(" --max-memory ").Append(options.Limits.MaxMemory
                                                              .ToString(CultureInfo.InvariantCulture));
                }

                if (options.Limits.AffinityMask != IntPtr.Zero)
                {
                    arguments.Append(" --affinity-mask ").Append(options.Limits.AffinityMask
                                                                 .ToInt32().ToString(CultureInfo.InvariantCulture));
                }
            }

            Dictionary <string, string> environment = null;

            AddDebug(ref environment, options.Debug);
            AddLogLevel(ref environment, options.LogLevel);
            AddListenerThreads(ref environment, options.ListenerThreads);

            if (arguments.Length > 0)
            {
                arguments.Append(" ");
            }

            arguments.Append(pipeName);

            m_process.StartInfo.Arguments = arguments.ToString();
            if (environment != null)
            {
                foreach (var kvp in environment)
                {
                    m_process.StartInfo.Environment.Add(kvp);
                }
            }

            m_process.StartInfo.UseShellExecute        = false;
            m_process.StartInfo.CreateNoWindow         = true;
            m_process.StartInfo.RedirectStandardError  = true;
            m_process.StartInfo.RedirectStandardOutput = true;
            m_process.StartInfo.RedirectStandardInput  = true;

            CommandLine = m_process.StartInfo.FileName + " " + m_process.StartInfo.Arguments;
        }
Ejemplo n.º 28
0
 public ExecutionProxy(IpcServiceClient <IExecutionService> svc)
 {
     this.svc = svc;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PauseCommandHandler"/> class.
 /// </summary>
 /// <param name="client">The client to be used to communicate with the FTP server.</param>
 public PauseCommandHandler([NotNull] IpcServiceClient <IFtpServerHost> client)
 {
     _client = client;
 }
Ejemplo n.º 30
0
 internal GuiDebuggerServiceProxy(IpcServiceClient <IGuiDebuggerService> client)
 {
     _client = client;
 }