コード例 #1
0
ファイル: Host.cs プロジェクト: ZhenghaiYe/iveely
        private static void Main(string[] args)
        {
            //搜索服务
            Init();
            WebSocketServer webSocket = new WebSocketServer(GetResult);
            webSocket.StartServer();

        }
コード例 #2
0
        public SocketConnection()
        {
            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;
        }