System.Net.WebSockets.ManagedWebSocket.CreateFromConnectedStream C# (CSharp) 메소드

CreateFromConnectedStream() 공개 정적인 메소드

Creates a ManagedWebSocket from a Stream connected to a websocket endpoint.
public static CreateFromConnectedStream ( Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment receiveBuffer = null ) : ManagedWebSocket
stream System.IO.Stream The connected Stream.
isServer bool true if this is the server-side of the connection; false if this is the client-side of the connection.
subprotocol string The agreed upon subprotocol for the connection.
keepAliveInterval TimeSpan The interval to use for keep-alive pings.
receiveBufferSize int The buffer size to use for received data.
receiveBuffer ArraySegment Optional buffer to use for receives.
리턴 ManagedWebSocket
        public static ManagedWebSocket CreateFromConnectedStream(
            Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval, int receiveBufferSize, ArraySegment<byte>? receiveBuffer = null)
        {
            return new ManagedWebSocket(stream, isServer, subprotocol, keepAliveInterval, receiveBufferSize, receiveBuffer);
        }

Usage Example

예제 #1
0
        public static WebSocket CreateFromStream(
            Stream stream,
            bool isServer,
            string?subProtocol,
            TimeSpan keepAliveInterval)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanRead || !stream.CanWrite)
            {
                throw new ArgumentException(!stream.CanRead ? SR.NotReadableStream : SR.NotWriteableStream, nameof(stream));
            }

            if (subProtocol != null)
            {
                WebSocketValidate.ValidateSubprotocol(subProtocol);
            }

            if (keepAliveInterval != Timeout.InfiniteTimeSpan && keepAliveInterval < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(keepAliveInterval), keepAliveInterval,
                                                      SR.Format(SR.net_WebSockets_ArgumentOutOfRange_TooSmall,
                                                                0));
            }

            return(ManagedWebSocket.CreateFromConnectedStream(stream, isServer, subProtocol, keepAliveInterval));
        }
All Usage Examples Of System.Net.WebSockets.ManagedWebSocket::CreateFromConnectedStream