Beispiel #1
0
 public void Setup()
 {
     server = new TcpServer();
     //server.Extensions = new object[] { new PerFrameDeflate(0, false) };
     server.MessageProcessor = this;
     server.ProtocolFactory = new CustomFactory();
     server.Start("test", new IPEndPoint(IPAddress.Loopback, 20000));
 }
Beispiel #2
0
        static void Main()
        {
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 6002);
            using(var server = new TcpServer())
            {
                server.ProtocolFactory = WebSocketsSelectorProcessor.Default;
                server.ConnectionTimeoutSeconds = 60;
                server.Received += msg =>
                {
                    var conn = (WebSocketConnection)msg.Connection;
                    string reply = (string)msg.Value + " / " + conn.Host;
                    Console.WriteLine("[server] {0}", msg.Value);
                    msg.Connection.Send(msg.Context, reply);
                };
                server.Start("abc", endpoint);
                Console.WriteLine("Server running");

                Console.ReadKey();
            }
            Console.WriteLine("Server dead; press any key");
            Console.ReadKey();
        }