/// <summary> /// </summary> /// <param name="configuration"></param> public ChannelTcpListener(ChannelTcpListenerConfiguration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); Configure(configuration); ChannelFactory = new TcpChannelFactory(); }
/// <summary> /// </summary> public ChannelTcpListener() { Configure( new ChannelTcpListenerConfiguration( () => new MicroMessageDecoder(new DataContractMessageSerializer()), () => new MicroMessageEncoder(new DataContractMessageSerializer())) ); ChannelFactory = new TcpChannelFactory(); }
/// <summary> /// </summary> /// <param name="configuration"></param> public ChannelTcpListener(ChannelTcpListenerConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } Configure(configuration); ChannelFactory = new TcpChannelFactory(); }
/// <summary> /// </summary> /// <param name="configuration"></param> public FreeSwitchListener(ChannelTcpListenerConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } Configure(configuration); ChannelFactory = new TcpChannelFactory(); _channels = new ConcurrentDictionary <string, ITcpChannel>(); }
public void when_creating_channel_with_invalid_address_then_fails() { var configuration = new MqttConfiguration { ConnectionTimeoutSecs = 2 }; var factory = new TcpChannelFactory(IPAddress.Loopback.ToString(), configuration); var ex = Assert.Throws <AggregateException> (() => factory.CreateAsync().Result); Assert.NotNull(ex); Assert.NotNull(ex.InnerException); Assert.True(ex.InnerException is MqttException); Assert.NotNull(ex.InnerException.InnerException); Assert.True(ex.InnerException.InnerException is SocketException); }
public async Task when_creating_channel_then_succeeds() { var configuration = new MqttConfiguration { ConnectionTimeoutSecs = 2 }; var listener = new TcpListener(IPAddress.Loopback, configuration.Port); listener.Start(); var factory = new TcpChannelFactory(IPAddress.Loopback.ToString(), configuration); var channel = await factory.CreateAsync(); Assert.NotNull(channel); Assert.True(channel.IsConnected); listener.Stop(); }
public void when_creating_channel_with_invalid_address_then_fails() { MqttConfiguration configuration = new MqttConfiguration { ConnectionTimeoutSecs = 2 }; TcpChannelFactory factory = new TcpChannelFactory(IPAddress.Loopback.ToString(), configuration); AggregateException ex = Assert.Throws <AggregateException>(() => { CK.MQTT.Sdk.IMqttChannel <byte[]> a = factory.CreateAsync().Result;//Why this variable must exist ???? }); Assert.NotNull(ex); Assert.NotNull(ex.InnerException); Assert.True(ex.InnerException is MqttException); Assert.NotNull(ex.InnerException.InnerException); Assert.True(ex.InnerException.InnerException is SocketException); }
/// <summary> /// </summary> public FreeSwitchListener() { Configure(new ChannelTcpListenerConfiguration(() => new FreeSwitchDecoder(), () => new FreeSwitchEncoder())); ChannelFactory = new TcpChannelFactory(); _channels = new ConcurrentDictionary <string, ITcpChannel>(); }