public void WriteMessage(HeartbeatRequest message, IBufferWriter <byte> output) { output.WriteString(message.GroupId); output.WriteInt(message.GenerationId); output.WriteString(message.MemberId); output.WriteNullableString(message.GroupInstanceId); }
public void WriteValue(IBufferWriter <byte> writer, MediaDescription value) { if (value == null) { throw new SerializationException("Media field must have value"); } SerializationHelpers.EnsureFieldIsPresent("Media field: Media", value.Media); SerializationHelpers.CheckForReserverdChars("Media field: Media", value.Media, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Media field: Port", value.Port); SerializationHelpers.CheckForReserverdChars("Media field: Port", value.Port, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Media field: Proto", value.Proto); SerializationHelpers.CheckForReserverdChars("Media field: Proto", value.Proto, ReservedChars); if (value.Fmts == null || !value.Fmts.Any()) { throw new SerializationException("Invalid Media field: fmt, expected required values"); } var field = $"m={value.Media} {value.Port} {value.Proto}"; writer.WriteString(field); foreach (var fmt in value.Fmts) { SerializationHelpers.EnsureFieldIsPresent("Media field: fmt", fmt); SerializationHelpers.CheckForReserverdChars("Media field: fmt", fmt, ReservedChars); writer.WriteString($" {fmt}"); } writer.WriteString(SDPSerializer.CRLF); }
public void WriteMessage(OffsetCommitRequest message, IBufferWriter <byte> output) { output.WriteString(message.GroupId); output.WriteInt(message.GenerationId); output.WriteString(message.MemberId); output.WriteString(message.GroupInstanceId); output.WriteArray(message.Topics, WriteTopic); }
public void WriteMessage(SyncGroupRequest message, IBufferWriter <byte> output) { output.WriteString(message.GroupId); output.WriteInt(message.GenerationId); output.WriteString(message.MemberId); output.WriteNullableString(message.GroupInstanceId); output.WriteArray(message.Assignments, WriteAssignment); }
public void WriteMessage(JoinGroupRequest message, IBufferWriter <byte> output) { output.WriteString(message.GroupId); output.WriteInt(message.SessionTimeout); output.WriteInt(message.RebalanceTimeout); output.WriteString(message.MemberId); output.WriteNullableString(message.GroupInstanceId); output.WriteString(message.ProtocolType); output.WriteArray(message.Protocols, WriteProtocol); }
public void WriteValue(IBufferWriter <byte> writer, ReadOnlySpan <byte> value) { if (value == null || value.IsEmpty) { return; } SerializationHelpers.CheckForReserverdBytes("Session information", value, ReservedBytes); writer.WriteString("i="); writer.Write(value); writer.WriteString(SDPSerializer.CRLF); }
public void WriteValue(IBufferWriter <byte> writer, ReadOnlySpan <byte> value) { if (value == null || value.IsEmpty) { writer.WriteString($"s= {SDPSerializer.CRLF}"); } else { SerializationHelpers.CheckForReserverdBytes("Session Name", value, ReservedBytes); writer.WriteString("s="); writer.Write(value); writer.WriteString(SDPSerializer.CRLF); } }
public void WriteMessage(RequestHeaderV1 message, IBufferWriter <byte> output) { output.WriteShort(message.ApiKey); output.WriteShort(message.ApiVersion); output.WriteInt(message.CorrelationId); output.WriteString(message.ClientId); }
public void WriteValue(IBufferWriter <byte> writer, Origin value) { if (value == null) { throw new SerializationException("Origin must have value"); } var userName = value.UserName; //it is "-" if the originating host does not support the concept of user IDs if (value.UserName == null) { userName = "******"; } else { SerializationHelpers.CheckForReserverdChars("Origin userame", value.UserName, ReservedChars); } SerializationHelpers.EnsureFieldIsPresent("Origin nettype", value.Nettype); SerializationHelpers.CheckForReserverdChars("Origin nettype", value.Nettype, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Origin addrtype", value.AddrType); SerializationHelpers.CheckForReserverdChars("Origin addrtype", value.AddrType, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Origin unicast address", value.UnicastAddress); SerializationHelpers.CheckForReserverdChars("Origin unicast address", value.UnicastAddress, ReservedChars); var field = $"o={userName} {value.SessionId} {value.SessionVersion} {value.Nettype} {value.AddrType} {value.UnicastAddress}{SDPSerializer.CRLF}"; writer.WriteString(field); }
ValueTask IAsyncBinaryWriter.WriteAsync(ReadOnlyMemory <char> chars, EncodingContext context, LengthFormat?lengthFormat, CancellationToken token) { ValueTask result; if (token.IsCancellationRequested) { #if NETSTANDARD2_1 result = new (Task.FromCanceled(token)); #else result = ValueTask.FromCanceled(token); #endif } else { result = new(); try { writer.WriteString(chars.Span, in context, lengthFormat: lengthFormat); } catch (Exception e) { #if NETSTANDARD2_1 result = new (Task.FromException(e)); #else result = ValueTask.FromException(e); #endif } } return(result); }
static void Serialize(string typeId, T value, IBufferWriter <byte> buffer) { // serialize type identifier buffer.WriteString(typeId, DefaultEncoding, lengthFormat: LengthEncoding); // serialize object to JSON using var jsonWriter = new Utf8JsonWriter(buffer, new() { SkipValidation = false, Indented = false }); JsonSerializer.Serialize(jsonWriter, value); }
public void WriteValue(IBufferWriter <byte> writer, RepeatTime value) { if (value.OffsetsFromStartTime == null || !value.OffsetsFromStartTime.Any()) { throw new SerializationException("Repeat Time field: offsets from start-time are required"); } var field = $"r={value.RepeatInterval.TotalSeconds} {value.ActiveDuration.TotalSeconds}"; writer.WriteString(field); foreach (var offset in value.OffsetsFromStartTime) { writer.WriteString(" " + offset.TotalSeconds.ToString()); } writer.WriteString(SDPSerializer.CRLF); }
public void WriteValue(IBufferWriter <byte> writer, EncriptionKey value) { if (value == null) { return; } SerializationHelpers.EnsureFieldIsPresent("Encription key field: method", value.Method); SerializationHelpers.CheckForReserverdChars("Encription key field: method", value.Method, ReservedChars); writer.WriteString($"k={value.Method}"); if (value.Value != null) { SerializationHelpers.CheckForReserverdChars("Encription key field: value", value.Value, ReservedChars); writer.WriteString($":{value.Value}"); } writer.WriteString(SDPSerializer.CRLF); }
public void WriteValue(IBufferWriter <byte> stream, TimingInfo value) { if (value == null) { throw new SerializationException("Timing must have value"); } var field = $"t={value.StartTime} {value.StopTime}{SDPSerializer.CRLF}"; stream.WriteString(field); }
public void WriteMessage(FetchRequest message, IBufferWriter <byte> output) { output.WriteInt(message.ReplicaId); output.WriteInt(message.MaxWaitTime); output.WriteInt(message.MinBytes); output.WriteInt(message.MaxBytes); output.WriteByte(message.IsolationLevel); output.WriteInt(message.SessionId); output.WriteInt(message.SessionEpoc); output.WriteArray(message.Topics, WriteTopic); output.WriteArray(message.ForgottenTopics, WriteForgottenTopic); output.WriteString(message.Rack); }
public void WriteValue(IBufferWriter <byte> writer, string value) { if (string.IsNullOrWhiteSpace(value)) { return; } SerializationHelpers.CheckForReserverdChars("Email field", value, ReservedChars); var field = $"e={value}{SDPSerializer.CRLF}"; writer.WriteString(field); }
public void WriteValue(IBufferWriter <byte> writer, string value) { if (string.IsNullOrWhiteSpace(value)) { throw new SerializationException("Attribute field must have value"); } SerializationHelpers.CheckForReserverdChars("Attribute field", value, ReservedChars); var field = $"a={value}{SDPSerializer.CRLF}"; writer.WriteString(field); }
public void WriteValue(IBufferWriter <byte> writer, Uri value) { if (value == null) { return; } if (!value.IsAbsoluteUri) { throw new SerializationException("Uri field value must be absolute uri"); } var uri = $"u={value.AbsoluteUri}{SDPSerializer.CRLF}"; writer.WriteString(uri); }
public void WriteValue(IBufferWriter <byte> writer, Bandwidth value) { if (value == null) { return; } SerializationHelpers.EnsureFieldIsPresent("Bandwith field Type", value.Type); SerializationHelpers.CheckForReserverdChars("Connection Data nettype", value.Type, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Bandwith field value", value.Value); SerializationHelpers.CheckForReserverdChars("Bandwith field value", value.Value, ReservedChars); var field = $"b={value.Type}:{value.Value}{SDPSerializer.CRLF}"; writer.WriteString(field); }
public void WriteMessage(ICollection <string> message, IBufferWriter <byte> output) { if (message == null) { output.WriteInt(-1); return; } else if (message.Count == 0) { output.WriteInt(0); return; } output.WriteInt(message.Count); foreach (var topic in message) { output.WriteString(topic); } }
public void WriteValue(IBufferWriter <byte> writer, ConnectionData value) { if (value == null) { return; } SerializationHelpers.EnsureFieldIsPresent("Connection Data nettype", value.Nettype); SerializationHelpers.CheckForReserverdChars("Connection Data nettype", value.Nettype, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Connection Data addrtype", value.AddrType); SerializationHelpers.CheckForReserverdChars("Connection Data addrtype", value.AddrType, ReservedChars); SerializationHelpers.EnsureFieldIsPresent("Connection Data unicast address", value.ConnectionAddress); SerializationHelpers.CheckForReserverdChars("Connection Data unicast address", value.ConnectionAddress, ReservedChars); var field = $"c={value.Nettype} {value.AddrType} {value.ConnectionAddress}{SDPSerializer.CRLF}"; writer.WriteString(field); }
public void WriteMessage(Message <TKey, TValue> message, IBufferWriter <byte> output) { //Produce Request(Version: 7) => transactional_id acks timeout[topic_data] // transactional_id => NULLABLE_STRING // acks => INT16 // timeout => INT32 // topic_data => topic[data] // topic => STRING // data => partition record_set // partition => INT32 // record_set => RECORDS output.WriteNullableString(null); // transactional_id => NULLABLE_STRING output.WriteShort(-1); // acks => INT16 output.WriteInt(5000); // timeout => INT32 output.WriteInt(1); // ??? output.WriteString(message.Topic); // topic => STRING output.WriteInt(1); // only one message output.WriteInt(0); // partitionId WriteRecordBatch(message, output); }
ValueTask IAsyncBinaryWriter.WriteAsync(ReadOnlyMemory <char> chars, EncodingContext context, LengthFormat?lengthFormat, CancellationToken token) { Task result; if (token.IsCancellationRequested) { result = Task.FromCanceled(token); } else { result = Task.CompletedTask; try { writer.WriteString(chars.Span, in context, lengthFormat: lengthFormat); } catch (Exception e) { result = Task.FromException(e); } } return(new ValueTask(result)); }
private void WriteProtocol(JoinGroupRequest.Protocol message, IBufferWriter <byte> output) { output.WriteString(message.Name); output.WriteBytes(message.Metadata); }
private void WriteAssignment(SyncGroupRequest.Assignment message, IBufferWriter <byte> output) { output.WriteString(message.MemberId); output.WriteBytes(message.AssignmentData); }
public void WriteMessage(OffsetFetchRequest message, IBufferWriter <byte> output) { output.WriteString(message.GroupId); output.WriteArray(message.Topics, WriteTopic); }
public void WriteTopic(FetchRequest.Topic message, IBufferWriter <byte> output) { output.WriteString(message.TopicName); output.WriteArray(message.Partitions, WriteTopicPartition); }
private void WriteTopic(OffsetCommitRequest.Topic message, IBufferWriter <byte> output) { output.WriteString(message.Name); output.WriteArray(message.Partitions, WritePartition); }
private void WriteTopic(OffsetFetchRequest.Topic message, IBufferWriter <byte> output) { output.WriteString(message.Name); output.WriteArray(message.PartitionIndexes); }
public void WriteForgottenTopic(FetchRequest.ForgottenTopicsData message, IBufferWriter <byte> output) { output.WriteString(message.TopicName); output.WriteArray(message.Partitions, (x, o) => o.WriteInt(x)); }