public ChatServer()
 {
     wss = new WebSocketServer(8181, "http://localhost", "ws://localhost:8181/CS");
     wss.Logger = CommunicationSystem.Logger.writer;
     wss.LogLevel = ServerLogLevel.Subtle;
     wss.ClientConnected += new ClientConnectedEventHandler(OnClientConnected);
     wss.Start();
     //KeepAlive();
 }
 public ChatServer()
 {
     wss = new WebSocketServer(8181, "http://localhost:8080", "ws://localhost:8181/chat");
     wss.Logger = Console.Out;
     wss.LogLevel = ServerLogLevel.Subtle;
     wss.ClientConnected += new ClientConnectedEventHandler(OnClientConnected);
     wss.Start();
     KeepAlive();
 }
Exemple #3
0
        public ChatServer()
        {
            wss = new WebSocketServer(8181, "http://localhost:8080", "ws://localhost:8181/chat");
            wss.Logger = Console.Out;
            wss.LogLevel = ServerLogLevel.Subtle;
            wss.ClientConnected += new ClientConnectedEventHandler(OnClientConnected);
            wss.Start();
            object obj = new object();
            for (int i = 0; i < cots.Count; i++)
            {
                var id = i;
                Thread thread = new Thread(delegate()
                {
                    this.StartSending(id);
                });
                thread.Start();
            };

            KeepAlive();
        }
 public WebSocketServerTest()
 {
     //使用默认的设置
     WSServer = new WebSocketServer();  
 }
        public SocketConnection()
        {
            logger             = new Logger();
            MaxBufferSize      = 1024 * 100;
            receivedDataBuffer = new byte[MaxBufferSize];
            FirstByte          = new byte[MaxBufferSize];
            LastByte           = new byte[MaxBufferSize];
            FirstByte[0]       = 0x00;
            LastByte[0]        = 0xFF;

            Handshake  = "HTTP/1.1 101 Web Socket Protocol Handshake" + Environment.NewLine;
            Handshake += "Upgrade: WebSocket" + Environment.NewLine;
            Handshake += "Connection: Upgrade" + Environment.NewLine;
            Handshake += "Sec-WebSocket-Origin: " + "{0}" + Environment.NewLine;
            Handshake += string.Format("Sec-WebSocket-Location: " + "ws://{0}:4141/chat" + Environment.NewLine, WebSocketServer.getLocalmachineIPAddress());
            Handshake += Environment.NewLine;

            New_Handshake  = "HTTP/1.1 101 Switching Protocols" + Environment.NewLine;
            New_Handshake += "Upgrade: WebSocket" + Environment.NewLine;
            New_Handshake += "Connection: Upgrade" + Environment.NewLine;
            New_Handshake += "Sec-WebSocket-Accept: {0}" + Environment.NewLine;
            New_Handshake += Environment.NewLine;
        }
Exemple #6
0
 public WebSocketServerTest()
 {
     //使用默认的设置
     WSServer = new WebSocketServer();
 }