예제 #1
0
        public void Pub(string subject, ReadOnlyMemory <byte> body, string replyTo = null)
        {
            if (body.Length > _maxPayload)
            {
                throw NatsException.ExceededMaxPayload(_maxPayload, body.Length);
            }

            PubCmd.Write(_writer, subject, replyTo, body);
        }
예제 #2
0
        public async Task WriteAsync(byte[] data)
        {
            if (data.Length > _maxPayloadSize)
            {
                throw NatsException.ExceededMaxPayload(_maxPayloadSize, data.Length);
            }

            await _stream.WriteAsync(data, 0, data.Length, _cancellationToken).ConfigureAwait(false);
        }
예제 #3
0
        public void Write(byte[] data)
        {
            if (data.Length > _maxPayloadSize)
            {
                throw NatsException.ExceededMaxPayload(_maxPayloadSize, data.Length);
            }

            _stream.Write(data, 0, data.Length);
        }
예제 #4
0
        public Task PubAsync(string subject, ReadOnlyMemory <byte> body, string replyTo = null)
        {
            if (body.Length > _maxPayload)
            {
                throw NatsException.ExceededMaxPayload(_maxPayload, body.Length);
            }

            return(PubCmd.WriteAsync(_writer, subject.AsMemory(), replyTo.AsMemory(), body));
        }
예제 #5
0
        public void Pub(string subject, string body, string replyTo = null)
        {
            var payload = NatsEncoder.GetBytes(body);

            if (payload.Length > _maxPayload)
            {
                throw NatsException.ExceededMaxPayload(_maxPayload, payload.Length);
            }

            PubCmd.Write(_writer, subject, replyTo, payload);
        }
예제 #6
0
        public Task PubAsync(string subject, string body, string replyTo = null)
        {
            var payload = NatsEncoder.GetBytes(body);

            if (payload.Length > _maxPayload)
            {
                throw NatsException.ExceededMaxPayload(_maxPayload, payload.Length);
            }

            return(PubCmd.WriteAsync(_writer, subject.AsMemory(), replyTo.AsMemory(), payload));
        }
예제 #7
0
        public async Task WriteAsync(IPayload data)
        {
            if (data.Size > _maxPayloadSize)
            {
                throw NatsException.ExceededMaxPayload(_maxPayloadSize, data.Size);
            }

            for (var i = 0; i < data.BlockCount; i++)
            {
                await _stream.WriteAsync(data[i], 0, data[i].Length, _cancellationToken).ConfigureAwait(false);
            }
        }
예제 #8
0
        public void Write(IPayload data)
        {
            if (data.Size > _maxPayloadSize)
            {
                throw NatsException.ExceededMaxPayload(_maxPayloadSize, data.Size);
            }

            for (var i = 0; i < data.BlockCount; i++)
            {
                _stream.Write(data[i], 0, data[i].Length);
            }
        }