public async Task <MsgOp> RequestAsync(string subject, string body, int?timeoutMs = null) { ThrowIfDisposed(); EnsureArg.IsNotNullOrWhiteSpace(subject, nameof(subject)); EnsureArg.IsNotNullOrWhiteSpace(body, nameof(body)); return(await DoRequestAsync(subject, NatsEncoder.GetBytes(body), timeoutMs).ConfigureAwait(false)); }
internal static ReadOnlySpan <byte> Generate(bool verbose, Credentials credentials, string name) { var opString = GenerateConnectionOpString( verbose, credentials ?? Credentials.Empty, name); return(NatsEncoder.GetBytes(opString).Span); }
private static void FillPreBody(byte[] buff, string subject, string bodyLenString, string replyTo = null) { buff[0] = Cmd[0]; buff[1] = Cmd[1]; buff[2] = Cmd[2]; buff[3] = NatsEncoder.SpaceByte; var curr = 3; curr = NatsEncoder.WriteSingleByteUtf8String(buff, subject, curr); if (replyTo != null) { buff[++curr] = NatsEncoder.SpaceByte; curr = NatsEncoder.WriteSingleByteUtf8String(buff, replyTo, curr); } buff[++curr] = NatsEncoder.SpaceByte; NatsEncoder.WriteSingleByteUtf8String(buff, bodyLenString, curr); }
private static void Fill(Span <byte> trg, ReadOnlySpan <char> subscriptionId, ReadOnlySpan <char> maxMessagesString) { trg[0] = Cmd[0]; trg[1] = Cmd[1]; trg[2] = Cmd[2]; trg[3] = Cmd[3]; trg[4] = Cmd[4]; trg[5] = NatsEncoder.SpaceByte; var nextSlot = 6; nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, subscriptionId); if (!maxMessagesString.IsEmpty) { trg[nextSlot++] = NatsEncoder.SpaceByte; nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, maxMessagesString); } NatsEncoder.WriteCrlf(trg, nextSlot); }
private static void Fill(Span <byte> trg, ReadOnlySpan <char> subject, ReadOnlySpan <char> subscriptionId, ReadOnlySpan <char> queueGroup) { trg[0] = Cmd[0]; trg[1] = Cmd[1]; trg[2] = Cmd[2]; trg[3] = NatsEncoder.SpaceByte; var nextSlot = 4; nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, subject); trg[nextSlot++] = NatsEncoder.SpaceByte; if (!queueGroup.IsEmpty) { nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, queueGroup); trg[nextSlot++] = NatsEncoder.SpaceByte; } nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, subscriptionId); NatsEncoder.WriteCrlf(trg, nextSlot); }
private static void FillPreBody(Span <byte> trg, ReadOnlySpan <char> subject, ReadOnlySpan <char> replyTo, ReadOnlySpan <char> bodySize) { trg[0] = Cmd[0]; trg[1] = Cmd[1]; trg[2] = Cmd[2]; trg[3] = NatsEncoder.SpaceByte; var nextSlot = 4; nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, subject); trg[nextSlot++] = NatsEncoder.SpaceByte; if (!replyTo.IsEmpty) { nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, replyTo); trg[nextSlot++] = NatsEncoder.SpaceByte; } nextSlot = NatsEncoder.WriteSingleByteChars(trg, nextSlot, bodySize); NatsEncoder.WriteCrlf(trg, nextSlot); }
public Task <MsgOp> RequestAsync(string subject, string body, CancellationToken cancellationToken = default) => RequestAsync(subject, NatsEncoder.GetBytes(body), cancellationToken);
public Task PubAsync(string subject, string body, string replyTo = null) => PubAsync(subject, NatsEncoder.GetBytes(body), replyTo);
public void Pub(string subject, string body, string replyTo = null) => Pub(subject, NatsEncoder.GetBytes(body), replyTo);
internal static byte[] Generate(string subject, string body, string replyTo = null) => Generate(subject, NatsEncoder.GetBytes(body), replyTo);
public string GetPayloadAsString() => NatsEncoder.GetString(Payload.Span);
public string GetPayloadAsString() { return(NatsEncoder.GetString(Payload)); }