示例#1
0
    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;
    }
示例#2
0
        private void InitColorBitmap()
        {
            WSRConfig cfg = WSRConfig.GetInstance();

            if (cfg.WSSmooth)
            {
                filter1 = new DepthFilteredSmoothing();
            }
            if (cfg.WSAverage)
            {
                filter2 = new DepthAveragedSmoothing();
            }
        }
示例#3
0
        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);
        }
示例#4
0
 private void InitColorBitmap() {
   WSRConfig cfg = WSRConfig.GetInstance();
   if (cfg.WSSmooth)  filter1 = new DepthFilteredSmoothing();
   if (cfg.WSAverage) filter2 = new DepthAveragedSmoothing();
 }