Exemple #1
0
        public WSHandler(WSConnection connection, IWSConnectionParameters options)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection), $"{nameof(connection)} is null.");
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options), $"{nameof(options)} is null.");
            }


            var buffers = connection.Buffers;

            if (buffers.IsIncomplete)
            {
                throw new NotSupportedException($"{nameof(WSConnection.Buffers)} is incomplete");
            }

            Connection     = connection;
            ReadOperations = new WSOperations(buffers, options);
            SendOperations = new WSOperations(buffers, options);

            Stopwatch = new Stopwatch();

            Heartbeat  = options.Heartbeat;
            ByteBuffer = buffers.ByteBuffer;
            CharBuffer = buffers.CharBuffer;
        }
Exemple #2
0
        public WSOperations(WSBuffers buffers, IWSConnectionParameters options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options), $"{nameof(options)} is null.");
            }

            if (buffers.IsIncomplete)
            {
                throw new ArgumentException($"{nameof(buffers)} is incomplete", nameof(buffers));
            }

            Stream = options.Stream;
            Buffer = buffers.ByteBuffer;
        }