Example #1
0
        public static void Start(HeyWebSocketServerSettings settings)
        {
            HeyWebSocketServer.OnMessage += (sender, data) =>
            {
                Console.WriteLine(data.Length);

                //// Send a ping.
                //WebSocketServerPro.Ping();

                //WebSocketServerPro.Send(new String('x', 0x10000));

                // Non-fragmented message.
                HeyWebSocketServer.Send(FinType.Set, OpcodeType.Text, "Hey!");

                // Send fragmented message.
                HeyWebSocketServer.Send(FinType.Clear, OpcodeType.Text, "Go");
                Thread.Sleep(1000);
                HeyWebSocketServer.Send(FinType.Set, OpcodeType.Continuation, "Hawks!");
            };

            TcpListener tcpListener = new TcpListener(IPAddress.IPv6Any, settings.Port);

            tcpListener.Start();
            Console.WriteLine("Listening on port {0} ...", settings.Port);

            while (true)
            {
                try
                {
                    using (TcpClient tcpClient = tcpListener.AcceptTcpClient())
                    {
                        Console.WriteLine("Connected: {0}", tcpClient.Client.RemoteEndPoint);
                        Console.WriteLine();

                        using (networkStream = tcpClient.GetStream())
                        {
                            logger = new HeyLogger();
                            AcceptCore();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Console.WriteLine();
                Console.WriteLine("Disconnected.");
            }
        }
Example #2
0
 private static void DoWs(HeyLogger logger, Stream sslStream, Socket clientSocket)
 {
     HeyWebSocketServer.Accept(logger, sslStream);
 }