/// <summary> /// Initializes a new instance of the <see cref="ClientSocket" /> class. /// </summary> /// <param name="clientConfiguration">The client configuration.</param> /// <param name="endPoint">The end point to connect to.</param> /// <param name="host">The host name (required for SSL).</param> /// <param name="version">Protocol version.</param> /// <param name="topVerCallback">Topology version update callback.</param> public ClientSocket(IgniteClientConfiguration clientConfiguration, EndPoint endPoint, string host, ClientProtocolVersion?version = null, Action <AffinityTopologyVersion> topVerCallback = null) { Debug.Assert(clientConfiguration != null); _topVerCallback = topVerCallback; _timeout = clientConfiguration.SocketTimeout; _socket = Connect(clientConfiguration, endPoint); _stream = GetSocketStream(_socket, clientConfiguration, host); ServerVersion = version ?? CurrentProtocolVersion; Validate(clientConfiguration); Handshake(clientConfiguration, ServerVersion); // Check periodically if any request has timed out. if (_timeout > TimeSpan.Zero) { // Minimum Socket timeout is 500ms. _timeoutCheckTimer = new Timer(CheckTimeouts, null, _timeout, TimeSpan.FromMilliseconds(500)); } // Continuously and asynchronously wait for data from server. // TaskCreationOptions.LongRunning actually means a new thread. TaskRunner.Run(WaitForMessages, TaskCreationOptions.LongRunning); }
/// <summary> /// Initializes a new instance of the <see cref="ClientSocket" /> class. /// </summary> /// <param name="clientConfiguration">The client configuration.</param> /// <param name="endPoint">The end point to connect to.</param> /// <param name="host">The host name (required for SSL).</param> /// <param name="onError">Error callback.</param> /// <param name="version">Protocol version.</param> public ClientSocket(IgniteClientConfiguration clientConfiguration, EndPoint endPoint, string host, Action onError = null, ClientProtocolVersion?version = null) { Debug.Assert(clientConfiguration != null); _onError = onError; _timeout = clientConfiguration.SocketTimeout; _socket = Connect(clientConfiguration, endPoint); _stream = GetSocketStream(_socket, clientConfiguration, host); ServerVersion = version ?? CurrentProtocolVersion; Validate(clientConfiguration); Handshake(clientConfiguration, ServerVersion); // Check periodically if any request has timed out. if (_timeout > TimeSpan.Zero) { // Minimum Socket timeout is 500ms. _timeoutCheckTimer = new Timer(CheckTimeouts, null, _timeout, TimeSpan.FromMilliseconds(500)); } // Continuously and asynchronously wait for data from server. TaskRunner.Run(WaitForMessages); }
/// <summary> /// Initializes a new instance of the <see cref="ClientSocket" /> class. /// </summary> /// <param name="clientConfiguration">The client configuration.</param> /// <param name="version">Protocol version.</param> public ClientSocket(IgniteClientConfiguration clientConfiguration, ClientProtocolVersion?version = null) { Debug.Assert(clientConfiguration != null); _socket = Connect(clientConfiguration); Handshake(_socket, version ?? CurrentProtocolVersion); }
/// <summary> /// Initializes a new instance of the <see cref="ClientSocket" /> class. /// </summary> /// <param name="clientConfiguration">The client configuration.</param> /// <param name="endPoint">The end point to connect to.</param> /// <param name="host">The host name (required for SSL).</param> /// <param name="version">Protocol version.</param> /// <param name="topVerCallback">Topology version update callback.</param> /// <param name="marshaller">Marshaller.</param> public ClientSocket(IgniteClientConfiguration clientConfiguration, EndPoint endPoint, string host, ClientProtocolVersion?version, Action <AffinityTopologyVersion> topVerCallback, Marshaller marshaller) { Debug.Assert(clientConfiguration != null); Debug.Assert(endPoint != null); Debug.Assert(!string.IsNullOrWhiteSpace(host)); Debug.Assert(topVerCallback != null); Debug.Assert(marshaller != null); _topVerCallback = topVerCallback; _marsh = marshaller; _timeout = clientConfiguration.SocketTimeout; _logger = (clientConfiguration.Logger ?? NoopLogger.Instance).GetLogger(GetType()); _socket = Connect(clientConfiguration, endPoint, _logger); _stream = GetSocketStream(_socket, clientConfiguration, host); ServerVersion = version ?? CurrentProtocolVersion; Validate(clientConfiguration); _features = Handshake(clientConfiguration, ServerVersion); if (clientConfiguration.EnableHeartbeats) { if (_features.HasFeature(ClientBitmaskFeature.Heartbeat)) { _heartbeatInterval = GetHeartbeatInterval(clientConfiguration); _heartbeatTimer = new Timer(SendHeartbeat, null, dueTime: _heartbeatInterval, period: TimeSpan.FromMilliseconds(-1)); } else { _logger.Warn("Heartbeats are enabled, but server does not support heartbeat feature."); } } // Check periodically if any request has timed out. if (_timeout > TimeSpan.Zero) { // Minimum Socket timeout is 500ms. _timeoutCheckTimer = new Timer(CheckTimeouts, null, _timeout, TimeSpan.FromMilliseconds(500)); } // Continuously and asynchronously wait for data from server. // TaskCreationOptions.LongRunning actually means a new thread. TaskRunner.Run(WaitForMessages, TaskCreationOptions.LongRunning); }
/// <summary> /// Initializes a new instance of the <see cref="ClientSocket" /> class. /// </summary> /// <param name="clientConfiguration">The client configuration.</param> /// <param name="version">Protocol version.</param> public ClientSocket(IgniteClientConfiguration clientConfiguration, ClientProtocolVersion?version = null) { Debug.Assert(clientConfiguration != null); _timeout = clientConfiguration.SocketTimeout; _socket = Connect(clientConfiguration); Handshake(version ?? CurrentProtocolVersion); // Check periodically if any request has timed out. if (_timeout > TimeSpan.Zero) { // Minimum Socket timeout is 500ms. _timeoutCheckTimer = new Timer(CheckTimeouts, null, _timeout, TimeSpan.FromMilliseconds(500)); } // Continuously and asynchronously wait for data from server. Task.Factory.StartNew(WaitForMessages); }