/// <summary> /// Runs the server and blocks until a shutdown command is received because the /// <see cref="OutOfProcessSilo" /> is being disposed of or because the parent process /// quits unexpectedly. /// </summary> /// <param name="address">The ip-address this endpoint shall bind itself to</param> /// <param name="minPort">The minimum port number to which this endpoint may be bound to</param> /// <param name="maxPort">The maximum port number to which this endpoint may be bound to</param> public void Run(IPAddress address, ushort minPort, ushort maxPort) { Console.WriteLine(ProcessWatchdog.Constants.BootingMessage); try { using (_endPoint) using (var host = new SubjectHost(_endPoint, _registry, OnSubjectHostDisposed, _customTypeResolver)) { _endPoint.CreateServant(OutOfProcessSilo.Constants.SubjectHostId, (ISubjectHost)host); _endPoint.Bind(address, minPort, maxPort); Console.WriteLine(_endPoint.LocalEndPoint.Port); Log.InfoFormat("Port sent to host process"); Console.WriteLine(ProcessWatchdog.Constants.ReadyMessage); _waitHandle.WaitOne(); Console.WriteLine(ProcessWatchdog.Constants.ShutdownMessage); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e.Message); } }
/// <summary> /// Initializes this object. /// </summary> public WatchdogHost() { _watchdog = new InternalWatchdog(); _endPoint = new SocketEndPoint(EndPointType.Server, PeerName); _endPoint.CreateServant(ObjectId, (IInternalWatchdog)_watchdog); _endPoint.Bind(IPAddress.Any); }
/// <summary> /// Initializes a new silo that hosts all objects in the same process it is used in, but with /// proxy and servant implementations in between. /// Is only really useful for debugging remoting. /// </summary> /// <param name="customTypeResolver">The type resolver, if any, that is used to resolve types by their assembly qualified name</param> public InProcessRemotingSilo(ITypeResolver customTypeResolver = null) { _customTypeResolver = customTypeResolver; const int subjectHostId = 0; _nextObjectId = subjectHostId + 1; _client = new SocketEndPoint(EndPointType.Client); _subjectHostProxy = _client.CreateProxy <ISubjectHost>(subjectHostId); _syncRoot = new object(); _server = new SocketEndPoint(EndPointType.Server); _registry = new DefaultImplementationRegistry(); _subjectHost = new SubjectHost(_server, _registry); _server.CreateServant(subjectHostId, (ISubjectHost)_subjectHost); _server.Bind(IPAddress.Loopback); _client.Connect(_server.LocalEndPoint, TimeSpan.FromSeconds(5)); }