public byte[] WriteInvocation(string methodName, object[] args, IReadOnlyList <string> excludedIds) { // Redis Invocation Format: // * Variable length integer: Number of excluded Ids // * For each excluded Id: // * Length prefixed string: ID // * SerializedHubMessage encoded by the format described by that type. using (var stream = new MemoryStream()) using (var writer = new BinaryWriterWithVarInt(stream, _utf8NoBom)) { if (excludedIds != null) { writer.WriteVarInt(excludedIds.Count); foreach (var id in excludedIds) { writer.Write(id); } } else { writer.WriteVarInt(0); } SerializedHubMessage.WriteAllSerializedVersions(writer, new InvocationMessage(methodName, argumentBindingException: null, args), _protocols); return(stream.ToArray()); } }
public byte[] WriteAck(int messageId) { // Acknowledgement Format: // * Variable length integer: Id using (var stream = new MemoryStream()) using (var writer = new BinaryWriterWithVarInt(stream, _utf8NoBom)) { writer.WriteVarInt(messageId); return(stream.ToArray()); } }
public byte[] WriteGroupCommand(RedisGroupCommand command) { // Group Command Format: // * Variable length integer: Id // * Length prefixed string: ServerName // * 1 byte: Action // * Length prefixed string: GroupName // * Length prefixed string: ConnectionId using (var stream = new MemoryStream()) using (var writer = new BinaryWriterWithVarInt(stream, _utf8NoBom)) { writer.WriteVarInt(command.Id); writer.Write(command.ServerName); writer.Write((byte)command.Action); writer.Write(command.GroupName); writer.Write(command.ConnectionId); return(stream.ToArray()); } }