public override void Start() { if (IsStarted()) { throw new InvalidOperationException("Server is already running."); } if (Port == 0) { throw new InvalidOperationException("Port must be set prior to starting server."); } if (KeyHash == null) { throw new InvalidOperationException("Key hash must be set prior to starting server."); } if (UseSSL && ServerCertificate == null) { throw new InvalidOperationException("ServerCertificate must be set if using SSL."); } //make sure we are configured properly ConnectorInfoManagerFactory.GetInstance().GetLocalManager(); _requestCount = 0; /* * the Java and .Net dates have a different starting point: zero milliseconds in Java corresponds to January 1, 1970, 00:00:00 GMT (aka “the epoch”). * In .Net zero milliseconds* corresponds to 12:00 A.M., January 1, 0001 GMT. * So the basic is to bridge over the reference points gap with adding (or substracting) the corresponding number of milliseconds * such that zero milliseconds in .Net is mapped to -62135769600000L milliseconds in Java. * This number of milliseconds corresponds to GMT zone, so do not forget to include your time zone offset into the calculations. */ _startDate = (DateTime.UtcNow.Ticks - 621355968000000000) / 10000; _pendingRequests.Clear(); TcpListener socket = CreateServerSocket(); ConnectionListener listener = new ConnectionListener(this, socket); listener.Start(); _listener = listener; if (MaxFacadeLifeTime > 0) { var statusChecker = new FacadeDisposer(new TimeSpan(0, MaxFacadeLifeTime, 0)); // Create an inferred delegate that invokes methods for the timer. TimerCallback tcb = statusChecker.Run; _timer = new Timer(tcb, null, new TimeSpan(0, MaxFacadeLifeTime, 0), new TimeSpan(0, Math.Min(MaxFacadeLifeTime, 10), 0)); } }