Example #1
0
 private static void BeginEmergencyExitChute(string pipeID)
 {
     try
     {
         _client = IPCClientFactory.Create();
         _client.VerbosityLevel = 1;
         _client.Initialize <IFLExService>("FLExEndpoint" + pipeID, _waitObject, CleanupHost);
         _client.RemoteCall("BridgeWorkOngoing", SignalCompletion);
     }
     catch (Exception)
     {
         CleanupHost();
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            Console.Title = "Client A";

            var serverAddress = "http://localhost:10000/";
            var clientAddress = "http://localhost:11111/";

            _ipcServer = new WebApiServer(serverAddress);
            _ipcServer.StartListening();

            _ipcClient = new WebApiClient(clientAddress, "api/values");

            ClientSendRequest();

            Console.ReadLine();

            _ipcServer.Dispose();
            _ipcClient.Dispose();
        }
        private bool _runStandAlone;         // debug mode, run with message boxes instead of connection to FLEx.
#endif
        /// <summary>
        /// Initialize the helper, setting up the local service endpoint and opening.
        /// </summary>
        /// <param name="commandLineArgs">The entire FieldWorks project folder path is in the '-p' option, if not 'obtain' operation.
        /// Must include the project folder and project name with "fwdata" extension.
        /// Empty is OK if not send_receive command.</param>
        public bool Init(Dictionary <string, string> commandLineArgs)
        {
#if DEBUG // this command line argument is only for debugging.
            if (commandLineArgs.ContainsKey("-runStandAlone"))
            {
                _runStandAlone = true;
                MessageBox.Show("connection opened");
                return(true);
            }
#else
            if (commandLineArgs.ContainsKey("-runStandAlone"))
            {
                throw new InvalidOperationException("The '-runStandAlone' command line option is not supported in a Release build.");
            }
#endif

            HostOpened = true;

            // The pipeID as set by FLEx to be used in setting the communication channels
            var pipeId = commandLineArgs["-pipeID"];

            _host = IPCHostFactory.Create();
            _host.VerbosityLevel = 1;
            var hostIsInitialized = _host.Initialize <FLExService, IFLExService>("FLExEndpoint" + pipeId, null, null);
            if (!hostIsInitialized)
            {
                HostOpened = false;
                // display messagebox and quit
                MessageBox.Show(CommonResources.kAlreadyRunning, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }
            //open host ready for business

            _client = IPCClientFactory.Create();
            _client.VerbosityLevel = 1;
            _client.Initialize <IFLExBridgeService>("FLExBridgeEndpoint" + pipeId, FLExService.WaitObject, null);
            if (!_client.RemoteCall("BridgeReady"))
            {
                _client = null;                 //FLEx isn't listening.
            }
            return(true);
        }
		private bool _runStandAlone; // debug mode, run with message boxes instead of connection to FLEx.
#endif
		/// <summary>
		/// Initialize the helper, setting up the local service endpoint and opening.
		/// </summary>
		/// <param name="commandLineArgs">The entire FieldWorks project folder path is in the '-p' option, if not 'obtain' operation.
		/// Must include the project folder and project name with "fwdata" extension.
		/// Empty is OK if not send_receive command.</param>
		public bool Init(Dictionary<string, string> commandLineArgs)
		{
#if DEBUG // this command line argument is only for debugging.
			if (commandLineArgs.ContainsKey("-runStandAlone"))
			{
				_runStandAlone = true;
				MessageBox.Show ("connection opened");
				return true;
			}
#else
			if (commandLineArgs.ContainsKey("-runStandAlone"))
			{
				throw new InvalidOperationException("The '-runStandAlone' command line option is not supported in a Release build.");
			}
#endif

			HostOpened = true;

			// The pipeID as set by FLEx to be used in setting the communication channels
			var pipeId = commandLineArgs["-pipeID"];

			_host = IPCHostFactory.Create();
			_host.VerbosityLevel = 1;
			var hostIsInitialized = _host.Initialize<FLExService, IFLExService>("FLExEndpoint" + pipeId, null, null);
			if (!hostIsInitialized)
			{
				HostOpened = false;
				// display messagebox and quit
				MessageBox.Show(CommonResources.kAlreadyRunning, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return false;
			}
			//open host ready for business

			_client = IPCClientFactory.Create();
			_client.VerbosityLevel = 1;
			_client.Initialize<IFLExBridgeService>("FLExBridgeEndpoint" + pipeId, FLExService.WaitObject, null);
			if (!_client.RemoteCall("BridgeReady"))
				_client = null;	//FLEx isn't listening.
			return true;
		}
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the issue.
        /// </remarks>
        private void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (HostOpened)
                {
                    _host.Close();
                    _host      = null;
                    HostOpened = false;
                }
                if (_client != null)
                {
                    _client.Close();
                    _client = null;
                }
            }

            IsDisposed = true;
        }
Example #6
0
		private static void BeginEmergencyExitChute(string pipeID)
		{
			try
			{
				_client = IPCClientFactory.Create();
				_client.VerbosityLevel = 1;
				_client.Initialize<IFLExService>("FLExEndpoint" + pipeID, _waitObject, CleanupHost);
				_client.RemoteCall("BridgeWorkOngoing", SignalCompletion);
			}
			catch (Exception)
			{
				CleanupHost();
			}
		}
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the issue.
		/// </remarks>
		private void Dispose(bool disposing)
		{
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (HostOpened)
				{
					_host.Close();
					_host = null;
					HostOpened = false;
				}
				if (_client != null)
				{
					_client.Close();
					_client = null;
				}
			}

			IsDisposed = true;
		}