/// <summary> /// Starts Web Server and notify user. /// This method does not check for webroot installation in Cache folder /// make sure you check for webroot installation by using IsWebrootInstalled() /// method with a true returned before calling this function to prevent any error /// </summary> public static void StartWebServer() { return; //WebSocketSharp.Server.HttpServer a = new WebSocketSharp.Server.HttpServer(port: Convert.ToInt32(Config.WebServerPort)); //a.DocumentRootPath = CacheDirectory; //a.Start(); string prefixes = "http://localhost:" + Config.WebServerPort + "/"; WebServer = new SMFileServer(CacheDirectory, prefixes); TrayIcon.NotifyUser("Web Server Started", "Web Server started and ready to use."); isWebServerStarted = true; }
public static void StartPrintServer() { StartRawPrinterService(); StartCOMPortDrawerService(); // start Web Socket print Server in a new thread //PrintServerThread = new Thread(StartWebSocketServer); //PrintServerThread.Start(); //if (PrintServerThread.ThreadState == ThreadState.Running) //{ // TrayIcon.NotifyUser("Print Server Started", "Print server has been started and ready to take messages"); // isPrintServerStarted = true; //} WSSServer = new WebSocketServer(IPAddress.Any, Convert.ToInt16(Config.PrintServerPort)); WSSServer.Log.File = "log.txt"; WSSServer.Log.Level = LogLevel.Debug; WSSServer.AddWebSocketService <SalonManager.Classes.WebSocketServerControllers.Printing>("/"); // default, legacy module WSSServer.AddWebSocketService <CommunicationServerBehavior>("/communication"); // legacy communication module - acts like a chat server WSSServer.AddWebSocketService <SalonManager.Classes.WebSocketServerControllers.RawPrinterDirect>("/raw-printers"); // access to raw printers using ?m=printername WSSServer.AddWebSocketService <SalonManager.Classes.WebSocketServerControllers.Communication>("/comm"); // another communication WSSServer.AddWebSocketService <SalonManager.Classes.WebSocketServerControllers.Utility>("/utility"); // utility to access system wise function such as list printers name, etc. WSSServer.Log.Debug("Server started"); WSSServer.KeepClean = false; try { WSSServer.Start(); TrayIcon.NotifyUser("Print Server Started", "Print server has been started and ready to take messages"); isPrintServerStarted = true; } catch (Exception e) { MessageBox.Show(@"Another application is listening to port " + Config.PrintServerPort + ".\nChange your port number and try again", "Print Server can not start", MessageBoxButtons.OK, MessageBoxIcon.Error); } }