Example #1
0
        public static int StopDeployment(Options.Stop options)
        {
            var deploymentServiceClient = ClientFactory.CreateDeploymentClient(options);

            try
            {
                deploymentServiceClient.StopDeployment(new StopDeploymentRequest
                {
                    Id          = options.DeploymentId,
                    ProjectName = options.ProjectName
                });
            }
            catch (Grpc.Core.RpcException e)
            {
                if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound)
                {
                    Ipc.WriteError(Ipc.ErrorCode.NotFound,
                                   $"Could not find deployment with ID {options.DeploymentId} in project {options.ProjectName}");
                    return(Program.ErrorExitCode);
                }

                throw;
            }

            return(Program.SuccessExitCode);
        }
Example #2
0
        void RealDispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (_hooks != null)
            {
                foreach (var hook in _hooks)
                {
                    hook.Dispose();
                }
            }

            _debug?.Dispose();
            _console?.Dispose();

            if (!_shallow)
            {
                ((IDisposable)HotKeys)?.Dispose();
            }

            Ipc?.Dispose();
            Game?.Dispose();
            Host?.Dispose();
        }
Example #3
0
        public static int ListDeployments(Options.List options)
        {
            var deploymentServiceClient = ClientFactory.CreateDeploymentClient(options);
            var listDeploymentsResult   = deploymentServiceClient.ListDeployments(new ListDeploymentsRequest
            {
                ProjectName = options.ProjectName
            });

            Ipc.WriteDeploymentInfo(listDeploymentsResult.Where(deployment =>
                                                                deployment.Status == Deployment.Types.Status.Running));

            return(Program.SuccessExitCode);
        }
        public void Kill()
        {
            if (Status == ProcessStatus.Stopped)
            {
                return;
            }
            Status = ProcessStatus.Stopped;
            try
            {
                if (!(Process?.HasExited ?? true))
                {
                    Process.Kill();
                    Process.WaitForExit();
                }
            }
            finally { }

            try
            {
                Ipc?.Kill();
            }
            finally { }
        }
Example #5
0
        private static int CreateDeploymentInternal <TOptions>(TOptions options, Func <TOptions, string> getLaunchConfigJson)
            where TOptions : Options.Create
        {
            var snapshotServiceClient   = ClientFactory.CreateSnapshotClient(options);
            var deploymentServiceClient = ClientFactory.CreateDeploymentClient(options);

            try
            {
                var deployment = new Deployment
                {
                    AssemblyId   = options.AssemblyName,
                    LaunchConfig = new LaunchConfig
                    {
                        ConfigJson = getLaunchConfigJson(options)
                    },
                    Name           = options.DeploymentName,
                    ProjectName    = options.ProjectName,
                    RuntimeVersion = options.RuntimeVersion
                };

                if (options.Cluster != null)
                {
                    deployment.ClusterCode = options.Cluster;
                }
                else if (options.Region != Options.DeploymentRegionCode.None)
                {
                    deployment.RegionCode = options.Region.ToString();
                }
                else
                {
                    throw new ArgumentException("Expected either --region or --cluster to be provided, but found neither.");
                }

                if (options.SnapshotPath != null)
                {
                    var snapshotId = UploadSnapshot(snapshotServiceClient, options);

                    if (string.IsNullOrEmpty(snapshotId))
                    {
                        return(Program.ErrorExitCode);
                    }

                    deployment.StartingSnapshotId = snapshotId;
                }

                if (options.Tags != null)
                {
                    foreach (var tag in options.Tags)
                    {
                        deployment.Tag.Add(tag);
                    }
                }

                var deploymentOp = deploymentServiceClient.CreateDeployment(new CreateDeploymentRequest
                {
                    Deployment = deployment
                }).PollUntilCompleted();

                if (deploymentOp.Result.Status != Deployment.Types.Status.Running)
                {
                    Ipc.WriteError(Ipc.ErrorCode.Unknown, "Deployment failed to start for an unknown reason.");
                    return(Program.ErrorExitCode);
                }
            }
            catch (Grpc.Core.RpcException e)
            {
                if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound)
                {
                    Ipc.WriteError(Ipc.ErrorCode.NotFound, e.Status.Detail);
                    return(Program.ErrorExitCode);
                }

                throw;
            }

            return(Program.SuccessExitCode);
        }
Example #6
0
        private static string UploadSnapshot(SnapshotServiceClient client, Options.Create options)
        {
            if (!File.Exists(options.SnapshotPath))
            {
                Ipc.WriteError(Ipc.ErrorCode.NotFound, $"Could not find snapshot file at: {options.SnapshotPath}");
                return(null);
            }

            // Read snapshot.
            var bytes = File.ReadAllBytes(options.SnapshotPath);

            if (bytes.Length == 0)
            {
                Ipc.WriteError(Ipc.ErrorCode.Unknown, $"Snapshot file at {options.SnapshotPath} has zero bytes.");
                return(null);
            }

            // Create HTTP endpoint to upload to.
            var snapshotToUpload = new Snapshot
            {
                ProjectName    = options.ProjectName,
                DeploymentName = options.DeploymentName
            };

            using (var md5 = MD5.Create())
            {
                snapshotToUpload.Checksum = Convert.ToBase64String(md5.ComputeHash(bytes));
                snapshotToUpload.Size     = bytes.Length;
            }

            var uploadSnapshotResponse =
                client.UploadSnapshot(new UploadSnapshotRequest {
                Snapshot = snapshotToUpload
            });

            snapshotToUpload = uploadSnapshotResponse.Snapshot;

            using (var httpClient = new HttpClient())
            {
                try
                {
                    var content = new ByteArrayContent(bytes);
                    content.Headers.Add("Content-MD5", snapshotToUpload.Checksum);

                    if (options.Environment == "cn-production")
                    {
                        content.Headers.Add("x-amz-server-side-encryption", "AES256");
                    }

                    using (var response = httpClient.PutAsync(uploadSnapshotResponse.UploadUrl, content).Result)
                    {
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            Ipc.WriteError(Ipc.ErrorCode.SnapshotUploadFailed, $"Snapshot upload returned non-OK error code: {response.StatusCode}");
                            return(null);
                        }
                    }
                }
                catch (HttpRequestException e)
                {
                    Ipc.WriteError(Ipc.ErrorCode.SnapshotUploadFailed, $"Failed to upload snapshot with following exception: {e.Message}");
                    return(null);
                }
            }

            // Confirm that the snapshot was uploaded successfully.
            var confirmUploadResponse = client.ConfirmUpload(new ConfirmUploadRequest
            {
                DeploymentName = snapshotToUpload.DeploymentName,
                Id             = snapshotToUpload.Id,
                ProjectName    = snapshotToUpload.ProjectName
            });

            return(confirmUploadResponse.Snapshot.Id);
        }
Example #7
0
        /// <summary>
        /// Run the driver...
        /// </summary>
        /// <returns>true on success</returns>
        public bool Run()
        {
            bool      blSuccess;
            bool      blRunning            = true;
            bool      blSetAppCapabilities = false;
            long      lResponseCharacterOffset;
            string    szJson;
            string    szMeta;
            string    szSession;
            string    szImageBlock;
            Ipc       ipc;
            SwordTask swordtask;

            TwainLocalScanner.ApiStatus apistatus;

            // Pipe mode starting...
            TwainDirect.Support.Log.Info("IPC mode starting...");

            // Set up communication with our server process...
            ipc = new Ipc(m_szIpc, false, null, null);
            ipc.MonitorPid(m_iPid);
            ipc.Connect();

            // TBD (hack)
            string szCapabilities = Sword.SaneListDrivers();

            TwainDirect.Support.Log.Info("TwainListDrivers: " + szCapabilities);
            JsonLookup jsonlookupCapabilities = new JsonLookup();

            jsonlookupCapabilities.Load(szCapabilities, out lResponseCharacterOffset);
            m_szTwainDriverIdentity = jsonlookupCapabilities.Get("scanners[0].sane");
            m_szNumberOfSheets      = jsonlookupCapabilities.Get("scanners[0].numberOfSheets[1]");
            m_szPixelFormat         = jsonlookupCapabilities.Get("scanners[0].pixelFormat[0]");
            m_szResolution          = jsonlookupCapabilities.Get("scanners[0].resolution[0]");

            m_iOffsetX = 0;
            m_iOffsetY = 0;
            m_iWidth   = 0;
            m_iHeight  = 0;
            int.TryParse(jsonlookupCapabilities.Get("scanners[0].offsetX[0]"), out m_iOffsetX);
            int.TryParse(jsonlookupCapabilities.Get("scanners[0].offsetY[0]"), out m_iOffsetY);
            int.TryParse(jsonlookupCapabilities.Get("scanners[0].width[1]"), out m_iWidth);
            int.TryParse(jsonlookupCapabilities.Get("scanners[0].height[1]"), out m_iHeight);

            // Loopy...
            while (blRunning)
            {
                // Read a command...
                szJson = ipc.Read();
                if (szJson == null)
                {
                    TwainDirect.Support.Log.Info("IPC channel disconnected...");
                    break;
                }

                // Log it...
                //TwainDirect.Support.Log.Info("");
                //TwainDirect.Support.Log.Info(szJson);

                // Parse the command...
                JsonLookup jsonlookup = new JsonLookup();
                if (!jsonlookup.Load(szJson, out lResponseCharacterOffset))
                {
                    continue;
                }

                // Dispatch the command...
                switch (jsonlookup.Get("method"))
                {
                default:
                    break;

                case "closeSession":
                    apistatus = DeviceScannerCloseSession(out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{\n" +
                            "    \"status\": \"" + apistatus + "\",\n" +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "createSession":
                    apistatus = DeviceScannerCreateSession(jsonlookup, out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "exit":
                    blRunning = false;
                    break;

                case "getSession":
                    apistatus = DeviceScannerGetSession(out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\": \"" + apistatus + "\"," +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "readImageBlock":
                    apistatus = DeviceScannerReadImageBlock(jsonlookup, out szImageBlock);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            "\"imageBlock\":\"" + szImageBlock + "\"" +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "readImageBlockMetadata":
                    apistatus = DeviceScannerReadImageBlockMetadata(jsonlookup, out szMeta);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        apistatus = DeviceScannerGetSession(out szSession);
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            "\"meta\":\"" + szMeta + "\"" +
                            (!string.IsNullOrEmpty(szSession) ? "," + szSession : "") +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "releaseImageBlocks":
                    apistatus = DeviceScannerReleaseImageBlocks(jsonlookup, out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "sendTask":
                    apistatus = DeviceScannerSendTask(jsonlookup, out swordtask, ref blSetAppCapabilities);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        if (string.IsNullOrEmpty(swordtask.GetTaskReply()))
                        {
                            blSuccess = ipc.Write
                                        (
                                "{" +
                                "\"status\":\"" + apistatus + "\"" +
                                "}"
                                        );
                        }
                        else
                        {
                            string szTaskReply = swordtask.GetTaskReply();
                            blSuccess = ipc.Write
                                        (
                                "{" +
                                "\"status\":\"" + apistatus + "\"," +
                                "\"taskReply\":" + szTaskReply +
                                "}"
                                        );
                        }
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\",\n" +
                            "\"exception\":\"" + swordtask.GetException() + "\"," +
                            "\"jsonKey\":\"" + swordtask.GetJsonExceptionKey() + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "startCapturing":
                    apistatus = DeviceScannerStartCapturing(ref blSetAppCapabilities, out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;

                case "stopCapturing":
                    apistatus = DeviceScannerStopCapturing(out szSession);
                    if (apistatus == TwainLocalScanner.ApiStatus.success)
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"," +
                            szSession +
                            "}"
                                    );
                    }
                    else
                    {
                        blSuccess = ipc.Write
                                    (
                            "{" +
                            "\"status\":\"" + apistatus + "\"" +
                            "}"
                                    );
                    }
                    if (!blSuccess)
                    {
                        TwainDirect.Support.Log.Info("IPC channel disconnected...");
                        blRunning = false;
                    }
                    break;
                }
            }

            // All done...
            TwainDirect.Support.Log.Info("IPC mode completed...");
            return(true);
        }
Example #8
0
        /// <summary>
        /// Test our ability to run the TWAIN driver using the TWAIN Direct Client-Scanner API
        /// as the controlling API.  This is easier to debug than running stuff
        /// across more than one process with the cloud involved...
        /// </summary>
        /// <returns></returns>
        public bool Test()
        {
            int ii;

            int[]      aiImageBlockNum;
            long       lResponseCharacterOffset;
            bool       blSts;
            bool       blEndOfJob;
            string     szJson;
            Thread     thread;
            Ipc        ipc;
            JsonLookup jsonlookup;

            // Create our objects...
            m_twainlocalonsane = new TwainLocalOnSane(m_szWriteFolder, m_szIpc, Process.GetCurrentProcess().Id);
            jsonlookup         = new JsonLookup();
            ipc = new Ipc(m_szIpc, true);

            // Run in a thread...
            thread = new Thread(RunTest);
            thread.Start();

            // Wait for a connection...
            ipc.Accept();

            // Create Session...
            #region Create Session...

            // Open the scanner...
            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"createSession\"," +
                "\"scanner\":\"" + m_szScanner + "\"" +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Get the result...
            szJson = ipc.Read();

            // Analyze the result...
            try
            {
                jsonlookup.Load(szJson, out lResponseCharacterOffset);
                if (jsonlookup.Get("status") != "success")
                {
                    TwainDirectSupport.Log.Error("createSession failed: " + jsonlookup.Get("status"));
                    return(false);
                }
            }
            catch
            {
                TwainDirectSupport.Log.Error("createSession failed: JSON error");
                return(false);
            }

            #endregion


            // Set TWAIN Direct Options...
            #region Set TWAIN Direct Options...

            string szTwainDirectOptions = File.ReadAllText(m_szTask);

            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"setTwainDirectOptions\"," +
                "\"task\":" + szTwainDirectOptions +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Get the result...
            szJson = ipc.Read();
            if (szJson == null)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            #endregion


            // Start Capturing...
            #region Start Capturing...

            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"startCapturing\"" +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Get the result...
            szJson = ipc.Read();
            if (szJson == null)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            #endregion


            // Loop until we run out of images...
            blEndOfJob      = false;
            aiImageBlockNum = null;
            while (true)
            {
                // Get Session (wait for image)...
                #region GetSession (wait for images)...

                // Stay in this loop unti we get an image or an error...
                while (true)
                {
                    // Get the current session info...
                    blSts = ipc.Write
                            (
                        "{" +
                        "\"method\":\"getSession\"" +
                        "}"
                            );
                    if (!blSts)
                    {
                        TwainDirectSupport.Log.Error("Lost our process...");
                        goto ABORT;
                    }

                    // Get the result...
                    szJson = ipc.Read();
                    if (szJson == null)
                    {
                        TwainDirectSupport.Log.Error("Lost our process...");
                        goto ABORT;
                    }

                    // Parse it...
                    jsonlookup = new JsonLookup();
                    jsonlookup.Load(szJson, out lResponseCharacterOffset);

                    // Bail if we're end of job...
                    if (jsonlookup.Get("endOfJob") == "true")
                    {
                        blEndOfJob = true;
                        break;
                    }

                    // Collect the data...
                    try
                    {
                        aiImageBlockNum = null;
                        for (ii = 0; ; ii++)
                        {
                            // Get the data...
                            string szNum = jsonlookup.Get("session.imageBlocks[" + ii + "]");
                            if ((szNum == null) || (szNum == ""))
                            {
                                break;
                            }

                            // Convert it...
                            int iTmp = int.Parse(szNum);

                            // Add it to the list...
                            if (aiImageBlockNum == null)
                            {
                                aiImageBlockNum    = new int[1];
                                aiImageBlockNum[0] = iTmp;
                            }
                            else
                            {
                                int[] aiTmp = new int[aiImageBlockNum.Length + 1];
                                aiImageBlockNum.CopyTo(aiTmp, 0);
                                aiTmp[aiTmp.Length - 1] = iTmp;
                                aiImageBlockNum         = aiTmp;
                            }
                        }
                    }
                    catch
                    {
                        // don't need to do anything...
                    }

                    // We got one!
                    if (aiImageBlockNum != null)
                    {
                        break;
                    }

                    // Snooze a bit...
                    Thread.Sleep(100);
                }

                // Bail if we're end of job...
                if (blEndOfJob)
                {
                    break;
                }

                #endregion


                // Read Image Block Metadata...
                #region Read Image Block Metadata...

                // Get this image's metadata...
                blSts = ipc.Write
                        (
                    "{" +
                    "\"method\":\"readImageBlockMetadata\"," +
                    "\"imageBlockNum\":" + aiImageBlockNum[0] +
                    "}"
                        );
                if (!blSts)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                // Get the result...
                szJson = ipc.Read();
                if (szJson == null)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                #endregion


                // Read Image Block...
                #region Read Image Block...

                // Get this image...
                blSts = ipc.Write
                        (
                    "{" +
                    "\"method\":\"readImageBlock\"," +
                    "\"imageBlockNum\":" + aiImageBlockNum[0] +
                    "}"
                        );
                if (!blSts)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                // Get the result...
                szJson = ipc.Read();
                if (szJson == null)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                #endregion


                // Release Image Block...
                #region Release Image Block...

                // Release this image...
                blSts = ipc.Write
                        (
                    "{" +
                    "\"method\":\"releaseImageBlocks\"," +
                    "\"imageBlockNum\":" + aiImageBlockNum[0] + "," +
                    "\"lastImageBlockNum\":" + aiImageBlockNum[0] +
                    "}"
                        );
                if (!blSts)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                // Get the result...
                szJson = ipc.Read();
                if (szJson == null)
                {
                    TwainDirectSupport.Log.Error("Lost our process...");
                    goto ABORT;
                }

                #endregion
            }


            // Stop Capturing...
            #region Stop Capturing...

            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"stopCapturing\"" +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Get the result...
            szJson = ipc.Read();
            if (szJson == null)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            #endregion


            // Close Session...
            #region Close Session...

            // Close the scanner...
            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"closeSession\"" +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Get the result...
            szJson = ipc.Read();
            if (szJson == null)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            // Exit the process...
            blSts = ipc.Write
                    (
                "{" +
                "\"method\":\"exit\"" +
                "}"
                    );
            if (!blSts)
            {
                TwainDirectSupport.Log.Error("Lost our process...");
                goto ABORT;
            }

            #endregion


            // All done...
ABORT:
            thread.Join();
            return(true);
        }
        public static IFoo GetFoo(this Ipc ipc, string name)
        {
            Ipc <Foo> wrapper = ipc.GetObject <Foo>(name);

            return(wrapper.GetProxy());
        }
Example #10
0
        public static IPrimitiveWrapper <int> GetProxy(this Ipc <int> wrapper)
        {
            int *linked = Memory.Link <int>(wrapper.Handle);

            return(new IntProxy(linked));
        }
Example #11
0
        public static IPrimitiveWrapper <int> GetInt32(this Ipc ipc, string name)
        {
            Ipc <int> wrapper = ipc.GetObject <int>(name);

            return(wrapper.GetProxy());
        }
Example #12
0
        public static IFoo GetProxy(this Ipc <Foo> wrapper)
        {
            Foo *linked = Memory.Link <Foo>(wrapper.Handle);

            return(new FooProxy(linked));
        }
Example #13
0
 public override IpcInterface GetService(byte[] name) =>
 Ipc.CreateService(Encoding.ASCII.GetString(name).TrimEnd('\0'));