Esempio n. 1
0
 public void Send(IWebSocketFrameWriter frame)
 {
     if (this.IsOpen)
     {
         this.webSocket.Send(frame);
     }
 }
Esempio n. 2
0
 public void Send(IWebSocketFrameWriter frame)
 {
     if (IsOpen)
     {
         webSocket.Send(frame);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebSocketConnection" /> class.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="dependencyUtility">The dependency utility.</param>
        public WebSocketConnection(TcpClient client, IDependencyUtility dependencyUtility)
        {
            _client            = client;
            _dependencyUtility = dependencyUtility ?? new DependencyUtility();
            _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ?? new SecurityContainer(null, SslProtocols.None, false, false, false);
            _routeTable        = _dependencyUtility.Resolve <IRouteTable>() ?? new RouteTable();
            _threadHelper      = _dependencyUtility.Resolve <IThreadHelper>() ?? new ThreadHelper();
            _logger            = _dependencyUtility.Resolve <ILogger>() ?? new Logger();

            _frameReader = new WebSocketFrameReader(_dependencyUtility);
            _frameWriter = new WebSocketFrameWriter(_dependencyUtility);
        }
 public void Send(IWebSocketFrameWriter frame)
 {
     if (frame == null)
     {
         throw new ArgumentNullException("frame is null!");
     }
     if (!closed)
     {
         byte[] array = frame.Get();
         lock (SendLock)
         {
             Stream.Write(array, 0, array.Length);
         }
         if (frame.Type == WebSocketFrameTypes.ConnectionClose)
         {
             closeSent = true;
         }
     }
 }
        public void Send(IWebSocketFrameWriter frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException("frame is null!");
            }
            if (this.closed)
            {
                return;
            }
            byte[] array    = frame.Get();
            object sendLock = this.SendLock;

            lock (sendLock)
            {
                this.Stream.Write(array, 0, array.Length);
                this.Stream.Flush();
            }
            if (frame.Type == WebSocketFrameTypes.ConnectionClose)
            {
                this.closeSent = true;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// It will send the given frame to the server.
        /// </summary>
        public void Send(IWebSocketFrameWriter frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException("frame is null!");
            }

            if (closed)
            {
                return;
            }

            byte[] rawData = frame.Get();
            lock (SendLock)
            {
                Stream.Write(rawData, 0, rawData.Length);
                Stream.Flush();
            }

            if (frame.Type == WebSocketFrameTypes.ConnectionClose)
            {
                closeSent = true;
            }
        }
        /// <summary>
        /// It will send the given frame to the server.
        /// </summary>
        public void Send(IWebSocketFrameWriter frame)
        {
            if (frame == null)
                throw new ArgumentNullException("frame is null!");

            if (closed)
                return;

            byte[] rawData = frame.Get();
            lock (SendLock)
            {
                Stream.Write(rawData, 0, rawData.Length);
                Stream.Flush();
            }

            if (frame.Type == WebSocketFrameTypes.ConnectionClose)
                closeSent = true;
        }
Esempio n. 8
0
 /// <summary>
 /// It will send the given frame to the server.
 /// </summary>
 public void Send(IWebSocketFrameWriter frame)
 {
     if (IsOpen)
         webSocket.Send(frame);
 }