public bool StartWebSocketServer() { WSRConfig cfg = WSRConfig.GetInstance(); int port = cfg.WebSocket; if (port < 0) { return false; } if (cfg.WSSmooth) filter1 = new DepthFilteredSmoothing(); if (cfg.WSAverage) filter2 = new DepthAveragedSmoothing(); ImageFormat format = cfg.WSType == "png" ? ImageFormat.Png : ImageFormat.Jpeg; Sockets = new List<IWebSocketConnection>(); Server = new WebSocketServer("ws://localhost:" + port); Server.Start(socket => { socket.OnOpen = () => { cfg.logInfo("WEBSCK", "Connected to: " + socket.ConnectionInfo.ClientIpAddress); lock (Sockets) { Sockets.Add(socket); } }; socket.OnClose = () => { cfg.logInfo("WEBSCK", "Disconnected from: " + socket.ConnectionInfo.ClientIpAddress); lock (Sockets) { Sockets.Remove(socket); } }; socket.OnMessage = message => { SendWebSocket(socket, GreenScreen(message), format); }; }); return true; }
private void InitColorBitmap() { WSRConfig cfg = WSRConfig.GetInstance(); if (cfg.WSSmooth) { filter1 = new DepthFilteredSmoothing(); } if (cfg.WSAverage) { filter2 = new DepthAveragedSmoothing(); } }
public bool StartWebSocketServer() { WSRConfig cfg = WSRConfig.GetInstance(); int port = cfg.WebSocket; if (port < 0) { return(false); } if (cfg.WSSmooth) { filter1 = new DepthFilteredSmoothing(); } if (cfg.WSAverage) { filter2 = new DepthAveragedSmoothing(); } ImageFormat format = cfg.WSType == "png" ? ImageFormat.Png : ImageFormat.Jpeg; Sockets = new List <IWebSocketConnection>(); Server = new WebSocketServer("ws://localhost:" + port); Server.Start(socket => { socket.OnOpen = () => { cfg.logInfo("WEBSCK", "Connected to: " + socket.ConnectionInfo.ClientIpAddress); lock (Sockets) { Sockets.Add(socket); } }; socket.OnClose = () => { cfg.logInfo("WEBSCK", "Disconnected from: " + socket.ConnectionInfo.ClientIpAddress); lock (Sockets) { Sockets.Remove(socket); } }; socket.OnMessage = message => { SendWebSocket(socket, GreenScreen(message), format); }; }); return(true); }
private void InitColorBitmap() { WSRConfig cfg = WSRConfig.GetInstance(); if (cfg.WSSmooth) filter1 = new DepthFilteredSmoothing(); if (cfg.WSAverage) filter2 = new DepthAveragedSmoothing(); }