Exemplo n.º 1
0
        /// <summary>
        /// Initialize the application and start the Alchemy Websockets server
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Initialize the server on port 81, accept any IPs, and bind events.
            var aServer = new WebSocketServer(81, IPAddress.Any)
                              {
                                  OnReceive = OnReceive,
                                  OnSend = OnSend,
                                  OnConnected = OnConnect,
                                  OnDisconnect = OnDisconnect,
                                  TimeOut = new TimeSpan(0, 5, 0)
                              };

            aServer.Start();

            // Accept commands on the console and keep it alive
            var command = string.Empty;
            while (command != "exit")
            {
                command = Console.ReadLine();
            }

            aServer.Stop();
        }
    static void Main(string[] args)
    {
        onlineConnections = new ConcurrentDictionary<string, UserContext>();
        stopwatch = new Stopwatch();
        mode = Modes.Depth1Byte;
        //mode = Modes.RGB;

        var aServer = new WebSocketServer(8100, System.Net.IPAddress.Any)
        {
            OnReceive = OnReceive,
            OnSend = OnSend,
            OnConnected = OnConnect,
            OnDisconnect = OnDisconnect,
            TimeOut = new TimeSpan(0, 5, 0)
        };
        aServer.Start();

        Console.WriteLine("Running Alchemy WebSocket Server ...");
        Console.WriteLine("[Type \"exit\" and hit enter to stop the server]");

        initializeKinect();

        // Accept commands on the console and keep it alive
        var command = string.Empty;
        while (command != "exit")
        {
            command = Console.ReadLine();
        }

        // Stop Kinect.
        if (null != sensor)
        {
            sensor.Stop();
        }

        aServer.Stop();
    }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string SslFileName = @"C:\Astros\AstrosSocket\astros.com.pfx";
            string SslPassword = @"c0sm0s";
            bool IsSecure = true;

            WebSocketServer wss = new WebSocketServer(11234, IPAddress.Any)
            {
                OnReceive = OnReceive,
                OnConnect = OnConnect,
                OnSend = OnSend,
                OnDisconnect = OnDisconnect,
                OnConnected = OnConnected,
                FlashAccessPolicyEnabled = true,
                IsSecure = IsSecure,
                SSLCertificate = new X509Certificate2(SslFileName, SslPassword)
            };

            Console.Title = "WebSocket Server Test";
            Console.WriteLine("Starting server...");
            wss.Start();
            Console.WriteLine(" ... Server started");

            Console.WriteLine("Waiting for incomming connections...");
            Console.WriteLine("[Press enter to end server]");

            string str = string.Empty;
            //while (string.IsNullOrEmpty(str) == true)
            {
                str = Console.ReadLine();
            }

            Console.WriteLine("Stopping server...");
            wss.Stop();
            Console.WriteLine(" ... Server stopped");

            // Force the program to terminate
            Environment.Exit(0);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            SocketServer = new WebSocketServer(ServerPort, System.Net.IPAddress.Any)
            {
                OnReceive = OnReceive,
                OnConnected = OnConnect,
                OnDisconnect = OnDisconnect,
                TimeOut = new TimeSpan(0, 5, 0)
            };

            SocketServer.Start();
            System.Threading.Timer t = new System.Threading.Timer(timerTick, null, 0, HeartBeat * 1000);

            Console.WriteLine("WebServer Successfuly Started !");
            Console.Write(">");

            string _text = string.Empty;

            while (_text.ToLower() != "!exit")
            {
                _text = Console.ReadLine().Trim();
                ConsoleSend(_text);
                Console.Write(">");
            }

            SocketServer.Stop();

            SocketServer = null;

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
            Environment.Exit(0);
        }