Ejemplo n.º 1
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="req">The request on which to establish the connection</param>
 /// <param name="bufferSize">The size of the buffer used to receive data</param>
 public WebSocketConnection(HttpRequest req, int bufferSize)
 {
     Request = req;
     ConnectionSocket = req.TcpClient.Client;
     _dataBuffer = new byte[bufferSize];
     GUID = Guid.NewGuid();
     Listen();            
 }
Ejemplo n.º 2
0
        public void ConnectSocket(string headers, HttpRequest req)
        {
            ShakeHands(headers.Split(Environment.NewLine.ToCharArray()),req.TcpClient.Client);
            var clientConnection = new WebSocketConnection(req);
            Connections.Add(clientConnection);
            clientConnection.Disconnected += ClientDisconnected;
            ClientConnected?.Invoke(clientConnection, EventArgs.Empty);

            clientConnection.DataReceived += DataReceivedFromClient;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="req">The request on which to establish the connection</param>
        public WebSocketConnection(HttpRequest req)
            : this(req, 1024)
        {

        }