コード例 #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.
            WSServer AServer = new WSServer(81, IPAddress.Any);
            AServer.DefaultOnReceive = new OnEventDelegate(OnReceive);
            AServer.DefaultOnSend = new OnEventDelegate(OnSend);
            AServer.DefaultOnConnect = new OnEventDelegate(OnConnect);
            AServer.DefaultOnDisconnect = new OnEventDelegate(OnDisconnect);
            AServer.TimeOut = new TimeSpan(0, 5, 0);

            AServer.Start();

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

            AServer.Stop();
        }