public ConnectionSender(IConnectionSender sender, CryptoAlgorithmType cryptoAlgorithmType, byte[] cryptoKey, byte[] nonce, IBytesPool bytesPool) { _sender = sender; if (cryptoAlgorithmType == CryptoAlgorithmType.Aes_Gcm_256) { _encrypter = new AesGcmEncrypter(cryptoKey, nonce, bytesPool); } else { throw new NotSupportedException(nameof(cryptoAlgorithmType)); } _bytesPool = bytesPool; }
public static bool TrySend <T>(this IConnectionSender connectionSender, T value) where T : IRocketMessage <T> { return(connectionSender.TrySend(bufferWriter => value.Export(bufferWriter, BytesPool.Shared))); }
public static async ValueTask SendAsync <T>(this IConnectionSender connectionSender, T value, CancellationToken cancellationToken = default) where T : IRocketMessage <T> { await connectionSender.SendAsync(bufferWriter => value.Export(bufferWriter, BytesPool.Shared), cancellationToken); }