// The disk file service allows you to serve and browse files from flash/disk storage public static void Main() { // Initialize logging Logger.Initialize(new DebugLogger(), LoggerLevel.Debug); // Create Http server pipeline ModuleManager ModuleManager = new ModuleManager(); // Create file/disk service for storage DiskFileService fileService = new DiskFileService(@"/", @"\WINFS\WebSite"); // Add the file module to pipeline and enable the file listing feature ModuleManager.Add(new FileModule(fileService) { AllowListing = true }); // Add the error module as the last module to pipeline ModuleManager.Add(new ErrorModule()); // Create the http server HttpService HttpServer = new HttpService(ModuleManager); // Sets interface ip address HttpServer.InterfaceAddress = IPAddress.GetDefaultLocalAddress(); // Starts Http service HttpServer.Start(); // Set local time SntpClient TimeService = new SntpClient(); TimeService.Synchronize(); }
public static void Main() { Server = new ServiceManager(LogType.Output, LogLevel.Info, @"\winfs"); //INITIALIZING : Server Services Server.InterfaceAddress = System.Net.IPAddress.GetDefaultLocalAddress().ToString(); Server.ServerName = "example"; Server.DnsSuffix = "iot.local"; // SERVICES: disable services Server.HttpEnabled = false; // SERVICES INIT: quickly enable/disable services //HttpInit(); //DhcpInit(); //DnsInit(); //SntpInit(); // SERVICES: Start all services //Server.StartAll(); // Test Harness: Set local time SntpClient TimeService = new SntpClient(); TimeService.Synchronize(); // enables basic authentication on server using AccountService class for user name and password //Server.HttpService.Add(new AuthenticationModule(new BasicAuthentication(new AccountService(), Server.ServerName))); //Type[] myTypes = new Type[2](typeof(TestMe), typeof(TestMe2)); //Type[] myTypes = new Type[2]; //myTypes[0] = typeof(TestMe); //myTypes[1] = typeof(TestMe2); foreach (DictionaryEntry properties in TypeUtility.GetProperties(typeof(TestMe2))) { string propName = (string)properties.Key; Type propType = (Type)properties.Value; Debug.Print("name: " + propName + " type: " + propType.ToString()); } ; }
public static void Main() { using (ServiceManager Server = new ServiceManager(LogType.Output, LogLevel.Info, @"\winfs")) { Server.LogInfo("MicroServer.Emulator", "Starting service manager main code"); ConfigManager.Load(Server.StorageRoot + @"\settings.xml"); // general interface information settings //Server.InterfaceAddress = ConfigManager.GetSetting("ipAddress", System.Net.IPAddress.GetDefaultLocalAddress().ToString()); Server.InterfaceAddress = "192.168.10.8"; Server.DnsSuffix = ConfigManager.GetSetting("dnsSuffix","iot.local"); Server.ServerName = ConfigManager.GetSetting("serverName", "mfhost"); // enable the services you would like to start Server.HttpEnabled = true; // dhcp server settings bool dhcpEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("dhcpEnabled", "false"), out dhcpEnabled)) { Server.DhcpEnabled = dhcpEnabled; Server.DhcpService.PoolRange( ConfigManager.GetSetting("startAddress", "192.168.50.100"), ConfigManager.GetSetting("endAddress", "192.168.50.254") ); //Server.DhcpService.PoolReservation("192.168.10.99", "000C291DBB7D"); Server.DhcpService.GatewayAddress = Server.InterfaceAddress; Server.DhcpService.SubnetMask = ConfigManager.GetSetting("subnetMask", "255.255.255.0"); Server.DhcpService.NameServers = new NameServerCollection(Server.InterfaceAddress); } // dns server settings bool dnsEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("dnsEnabled", "false"), out dnsEnabled)) Server.DnsEnabled = dnsEnabled; // sntp server settings bool sntpEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("sntpEnabled", "false"), out sntpEnabled)) Server.SntpEnabled = sntpEnabled; // event handlers for dhcp service Server.DhcpService.OnDhcpMessageReceived += DhcpService_OnDhcpMessageReceived; Server.DhcpService.OnDhcpMessageSent += DhcpService_OnDhcpMessageSent; Server.DhcpService.OnLeaseAcknowledged += DhcpService_OnLeaseAcknowledged; Server.DhcpService.OnLeaseDeclined += DhcpService_OnLeaseDeclined; Server.DhcpService.OnLeaseReleased += DhcpService_OnLeaseReleased; // event handlers for dns service Server.DnsService.OnDnsMessageReceived += DnsService_OnDnsMessageReceived; Server.DnsService.OnDnsMessageSent += DnsService_OnDnsMessageSent; // event handlers for sntp service Server.SntpService.OnSntpMessageReceived += SntpService_OnSntpMessageReceived; Server.SntpService.OnSntpMessageSent += SntpService_OnSntpMessageSent; // start all enabled services Server.StartAll(); Server.LogInfo("MicroServer.Emulator", "Ending service manager main code"); } if (SystemInfo.IsEmulator) { SntpClient TimeService = new SntpClient(); TimeService.Synchronize(); } }
public static void Main() { using (ServiceManager Server = new ServiceManager(LogType.Output, LogLevel.Info, @"\winfs")) { Server.LogInfo("MicroServer.Emulator", "Starting service manager main code"); ConfigManager.Load(Server.StorageRoot + @"\settings.xml"); // general interface information settings //Server.InterfaceAddress = ConfigManager.GetSetting("ipAddress", System.Net.IPAddress.GetDefaultLocalAddress().ToString()); Server.InterfaceAddress = "192.168.10.8"; Server.DnsSuffix = ConfigManager.GetSetting("dnsSuffix", "iot.local"); Server.ServerName = ConfigManager.GetSetting("serverName", "mfhost"); // enable the services you would like to start Server.HttpEnabled = true; // dhcp server settings bool dhcpEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("dhcpEnabled", "false"), out dhcpEnabled)) { Server.DhcpEnabled = dhcpEnabled; Server.DhcpService.PoolRange( ConfigManager.GetSetting("startAddress", "192.168.50.100"), ConfigManager.GetSetting("endAddress", "192.168.50.254") ); //Server.DhcpService.PoolReservation("192.168.10.99", "000C291DBB7D"); Server.DhcpService.GatewayAddress = Server.InterfaceAddress; Server.DhcpService.SubnetMask = ConfigManager.GetSetting("subnetMask", "255.255.255.0"); Server.DhcpService.NameServers = new NameServerCollection(Server.InterfaceAddress); } // dns server settings bool dnsEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("dnsEnabled", "false"), out dnsEnabled)) { Server.DnsEnabled = dnsEnabled; } // sntp server settings bool sntpEnabled; if (ParseUtility.TryParseBool(ConfigManager.GetSetting("sntpEnabled", "false"), out sntpEnabled)) { Server.SntpEnabled = sntpEnabled; } // event handlers for dhcp service Server.DhcpService.OnDhcpMessageReceived += DhcpService_OnDhcpMessageReceived; Server.DhcpService.OnDhcpMessageSent += DhcpService_OnDhcpMessageSent; Server.DhcpService.OnLeaseAcknowledged += DhcpService_OnLeaseAcknowledged; Server.DhcpService.OnLeaseDeclined += DhcpService_OnLeaseDeclined; Server.DhcpService.OnLeaseReleased += DhcpService_OnLeaseReleased; // event handlers for dns service Server.DnsService.OnDnsMessageReceived += DnsService_OnDnsMessageReceived; Server.DnsService.OnDnsMessageSent += DnsService_OnDnsMessageSent; // event handlers for sntp service Server.SntpService.OnSntpMessageReceived += SntpService_OnSntpMessageReceived; Server.SntpService.OnSntpMessageSent += SntpService_OnSntpMessageSent; // start all enabled services Server.StartAll(); Server.LogInfo("MicroServer.Emulator", "Ending service manager main code"); } if (SystemInfo.IsEmulator) { SntpClient TimeService = new SntpClient(); TimeService.Synchronize(); } }