public MediationStream(TlsHandler owner) { this.owner = owner; }
public MediationStream(TlsHandler owner) { this.syncReadResult = new SynchronousReadAsyncResult(); this.owner = owner; }
public MediationStream(TlsHandler owner) { this.syncReadResult = new SynchronousAsyncResult <int>(); this.owner = owner; }
Func<IPAddress, int, Task<IChannel>> CreateChannelFactory(IotHubConnectionString iotHubConnectionString, MqttTransportSettings settings) { return (address, port) => { IEventLoopGroup eventLoopGroup = EventLoopGroupPool.TakeOrAdd(this.eventLoopGroupKey); Func<Stream, SslStream> streamFactory = stream => new SslStream(stream, true, settings.RemoteCertificateValidationCallback); ClientTlsSettings clientTlsSettings; clientTlsSettings = settings.ClientCertificate != null ? new ClientTlsSettings(iotHubConnectionString.HostName, new List<X509Certificate> { settings.ClientCertificate }) : new ClientTlsSettings(iotHubConnectionString.HostName); Bootstrap bootstrap = new Bootstrap() .Group(eventLoopGroup) .Channel<TcpSocketChannel>() .Option(ChannelOption.TcpNodelay, true) .Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default) .Handler(new ActionChannelInitializer<ISocketChannel>(ch => { var tlsHandler = new TlsHandler(streamFactory, clientTlsSettings); ch.Pipeline .AddLast( tlsHandler, MqttEncoder.Instance, new MqttDecoder(false, 256 * 1024), this.mqttIotHubAdapterFactory.Create(this.OnConnected, this.OnMessageReceived, this.OnError, iotHubConnectionString, settings)); })); this.ScheduleCleanup(() => { EventLoopGroupPool.Release(this.eventLoopGroupKey); return TaskConstants.Completed; }); return bootstrap.ConnectAsync(address, port); }; }