public async Task SendBytesAsync(byte[] data, bool compress = false, bool encrypt = false, bool close = false) { var builder = new SimpleMessage(MessageType.Bytes, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetBytes(data); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false); }
public async Task SendMessageAsync(string message, bool compress = false, bool encrypt = false, bool close = false) { var builder = new SimpleMessage(MessageType.Message, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetMessage(message); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false); }
public async Task SendMessageContractAsync(IMessageContract contract, bool compress = false, bool encrypt = false, bool close = false) { var builder = new SimpleMessage(MessageType.MessageContract, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetHeaderString(contract.MessageHeader) .SetBytes(contract.SerializeToBytes()); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false); }
public async Task SendMessageWithMetadataAsync(object message, IDictionary <object, object> metadata, bool compress = false, bool encrypt = false, bool close = false) { var builder = new SimpleMessage(MessageType.MessageWithMetadata, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetMetadata(metadata) .SetBytes(ObjectSerializer.SerializeObjectToBytes(message)) .SetHeaderString(message.GetType().AssemblyQualifiedName); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false); }
public async Task SendCustomHeaderAsync(int id, byte[] data, byte[] header, bool compress = false, bool encrypt = false, bool close = false) { var client = GetClient(id); var builder = new SimpleMessage(MessageType.CustomHeader, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetHeader(header) .SetBytes(data) .SetSendClient(client); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false, id); }
public async Task SendObjectAsync(object obj, bool compress = false, bool encrypt = false, bool close = false) { if (ObjectSerializer == null) { throw new Exception("No ObjectSerializer is currently set."); } var builder = new SimpleMessage(MessageType.Object, this, Debug) .CompressMessage(compress) .EncryptMessage(encrypt) .SetBytes(ObjectSerializer.SerializeObjectToBytes(obj)) .SetHeaderString(obj.GetType().AssemblyQualifiedName); await builder.BuildAsync(); SendToSocket(builder.PayLoad, close, false); }