public ServerMain() { if (Instance == null) { Instance = this; } else { return; } this.Sessions = new List <AuthenticatedToken>(); this.mySQL = new SQLQueries(); this.myStats = new List <ServerStats>(); }
static void Main(string[] args) { ServerMain serverMain = new ServerMain(); Uri baseAddress = new Uri("http://127.0.0.1:3030"); ServiceHost serviceHost = new ServiceHost(typeof(RandomServer), baseAddress); BasicHttpBinding binding = new BasicHttpBinding(); binding.OpenTimeout = new TimeSpan(0, 5, 0); binding.CloseTimeout = new TimeSpan(0, 5, 0); binding.SendTimeout = new TimeSpan(0, 10, 0); binding.ReceiveTimeout = new TimeSpan(long.MaxValue); binding.MaxBufferPoolSize = 1024 * 1024 * 10; binding.MaxReceivedMessageSize = 1024 * 1024 * 10; binding.ReaderQuotas.MaxArrayLength = 1000000; binding.ReaderQuotas.MaxStringContentLength = 1000000; ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; smb.HttpGetEnabled = false; serviceHost.Description.Behaviors.Add(smb); ServiceEndpoint tst = serviceHost.AddServiceEndpoint(typeof(IRandomServer), new WebHttpBinding(), "get"); tst.EndpointBehaviors.Add(new WebHttpBehavior()); serviceHost.AddServiceEndpoint(typeof(IRandomServer), binding, baseAddress); serviceHost.CloseTimeout = new TimeSpan(long.MaxValue); serviceHost.OpenTimeout = new TimeSpan(long.MaxValue); serviceHost.Open(); Console.WriteLine("The service is ready at {0}", baseAddress); Console.WriteLine("Press <Enter> to stop the service."); Console.ReadLine(); // Close the ServiceHost. serviceHost.Close(); }