private void TryConnect() { ChannelConnecting?.Invoke(this); Socket = new Socket(Binding.IpAddress.AddressFamily, SocketType.Stream, ProtocolType.IP); try { Socket.BeginConnect(Binding.IpAddress, Binding.Port, EndConnect, null); } catch (Exception) { TryReconnect(); } }
private async void TryConnect() { ChannelConnecting?.Invoke(this); Socket = new Socket(Binding.IpAddress.AddressFamily, SocketType.Stream, ProtocolType.IP); try { await Socket.ConnectAsync(Binding.IpAddress, Binding.Port); Socket.NoDelay = true; Socket.LingerState = new LingerOption(true, 1); Connected(); } catch (Exception) { TryReconnect(); } }
public BatchChannel(SocketOptions options, IChannel channel, BatchLetterBuilder batchBuilder) { _channel = channel; _options = options.Batch; _batchBuilder = batchBuilder; _channel.ChannelConnected += abstractChannel => ChannelConnected?.Invoke(this); _channel.ChannelDisconnected += ChannelOnDisconnected; _channel.ChannelQueueEmpty += abstractChannel => { /* NOOP */ }; _channel.ChannelInitialized += ChannelOnInitialized; _channel.ChannelConnecting += abstractChannel => ChannelConnecting?.Invoke(this); _channel.ChannelDisconnecting += (abstractChannel, reason) => ChannelDisconnecting?.Invoke(this, reason); _channel.Received += ChannelOnReceived; _channel.Sent += ChannelOnSent; _channel.FailedToSend += ChannelOnFailedToSend; _slidingTimeoutTimer = new Timer(SlidingTimeoutTimerOnElapsed, null, -1, -1); }