protected override void HandleSetup(RSocketProtocol.Setup message, ReadOnlySequence <byte> metadata, ReadOnlySequence <byte> data)
        {
            this._setupData     = data.ConvertToString();
            this._setupMetadata = metadata.ConvertToString();

            Console.WriteLine($"setupData: {this._setupData}, setupMetadata: {this._setupMetadata}");

            if (message.HasResume)
            {
                throw new UnsupportedSetupException("Resume operations are not supported.");
            }

            if (message.CanLease)
            {
                throw new UnsupportedSetupException("Lease operations are not supported.");
            }
        }
Пример #2
0
        protected sealed override Task Process(Header header, SequenceReader <byte> reader)
        {
            if (Interlocked.CompareExchange(ref this._hasSetup, 1, 0) == 0)
            {
                if (header.Type == Types.Setup)
                {
                    try
                    {
                        var setup = new Setup(header, ref reader);
                        this.Setup = setup;
                        this.HandleSetup(setup, setup.ReadMetadata(reader), setup.ReadData(reader));

                        if (setup.KeepAlive > 0 && setup.Lifetime > 0)
                        {
                            this.StartKeepAlive(TimeSpan.FromMilliseconds(setup.KeepAlive), TimeSpan.FromMilliseconds(setup.Lifetime));
                            this.SendKeepAlive(0, false);
                        }
                    }
                    catch (RSocketErrorException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        Console.WriteLine($"{ex.Message} {ex.StackTrace}");
#endif
                        throw new RejectedSetupException($"An exception occurred while handling setup: {ex.Message}");
                    }

                    return(Task.CompletedTask);
                }

                throw new InvalidSetupException("SETUP frame must be received before any others");
            }

            return(base.Process(header, reader));
        }
Пример #3
0
 protected override void HandleSetup(RSocketProtocol.Setup message, ReadOnlySequence <byte> metadata, ReadOnlySequence <byte> data)
 {
 }