Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public static bool TrySend <T>(this IConnectionSender connectionSender, T value)
     where T : IRocketMessage <T>
 {
     return(connectionSender.TrySend(bufferWriter => value.Export(bufferWriter, BytesPool.Shared)));
 }
Exemplo n.º 3
0
 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);
 }