private void Start() { DataPublisher publisher = GetComponent <DataPublisher>(); m_temperaturePort = new DataPublisher.DataPort("Temperature"); publisher.SetPort(m_temperaturePort); }
private void Update() { if (IsActive && m_mouseEventReady) { Vector2 mousePos = TileUtils.NormalizedMousePosition(); GameObject obj = TileManagerScript.TileManager.GetGameObject(mousePos); DataPublisher publisher = obj?.GetComponent <DataPublisher>(); if (m_state == State.WirePlacing) { DrawLine(mousePos); if (m_mouseEventReady && Input.GetMouseButtonUp(MouseUtils.PRIMARY_MOUSE_BUTTON) && publisher != null && m_publisherFrom != publisher) { m_state = State.SelectPortTo; m_selectedPortIndex = -1; ShowPortList(mousePos, publisher.PortList); } } else if (m_state == State.Idle) { if (Input.GetMouseButtonUp(MouseUtils.PRIMARY_MOUSE_BUTTON) && publisher != null) { m_fromPosition = mousePos; m_state = State.SelectPortFrom; m_publisherFrom = publisher; ShowPortList(mousePos, publisher.PortList); } } } m_mouseEventReady = true; }
/// <summary> /// Releases the unmanaged resources used by the <see cref="UnsynchronizedClientSubscription"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { // Remove reference to parent m_parent = null; // Dispose base time rotation timer if ((object)m_baseTimeRotationTimer != null) { m_baseTimeRotationTimer.Dispose(); m_baseTimeRotationTimer = null; } if ((object)m_workingBuffer != null) { m_workingBuffer.Dispose(); } // Dispose Iaon session this.DisposeTemporalSession(ref m_iaonSession); } } finally { m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
private void Start() { DataPublisher publisher = GetComponent <DataPublisher>(); m_presencePort = new DataPublisher.DataPort("IsDetected"); publisher.SetPort(m_presencePort); }
public BAMPublisherInterceptor() { RestApiConf restApiConf = new RestApiConf(); set_conf(restApiConf); dataPublisher = new DataPublisher(restApiConf); string streamDef = "{" + "'name':'BAM_WCF_MESSAGE_TRACE'," + "'version':'1.0.0'," + "'nickName':'MessageTracerAgent'," + "'correlationData':[" + "{" + "'name':'activity_id'," + "'type':'STRING'" + "}"+ "]," + "'payloadData':[" + "{" + "'name':'message'," + "'type':'STRING'" + "}" + "]" + "}"; dataPublisher.defineStream(streamDef); }
/// <summary> /// Releases the unmanaged resources used by the <see cref="ClientConnection"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { if ((object)m_pingTimer != null) { m_pingTimer.Elapsed -= m_pingTimer_Elapsed; m_pingTimer.Dispose(); m_pingTimer = null; } if ((object)m_reconnectTimer != null) { m_reconnectTimer.Elapsed -= m_reconnectTimer_Elapsed; m_reconnectTimer.Dispose(); m_reconnectTimer = null; } DataChannel = null; m_commandChannel = null; m_ipAddress = null; m_subscription = null; m_parent = null; } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
// IMover end private void Start() { m_tileComponent = GetComponent <TileObject>(); m_direction = m_tileComponent.Direction; m_consumerComponent = GetComponent <EnergyConsumer>(); m_animator = GetComponent <Animator>(); if (m_animator != null) { m_animator.enabled = false; m_animationEnabled = false; } else { Debug.LogError("Animator is not found for conveyer."); } DataPublisher publisher = GetComponent <DataPublisher>(); if (publisher == null) { Debug.LogWarning("There is no publisher attached to conveyer object!"); return; } m_directionPort = new DataPublisher.DataPort("IsReversed"); m_speedPort = new DataPublisher.DataPort("Speed"); publisher.SetPort(m_directionPort); publisher.SetPort(m_speedPort); }
/// <summary> /// Creates a new <see cref="SubscriberConnection"/> instance. /// </summary> /// <param name="parent">Parent data publisher.</param> /// <param name="clientID">Client ID of associated connection.</param> /// <param name="serverCommandChannel"><see cref="TcpServer"/> command channel used to lookup connection information.</param> /// <param name="clientCommandChannel"><see cref="TcpClient"/> command channel used to lookup connection information.</param> public SubscriberConnection(DataPublisher parent, Guid clientID, IServer serverCommandChannel, IClient clientCommandChannel) { m_parent = parent; ClientID = clientID; ServerCommandChannel = serverCommandChannel; ClientCommandChannel = clientCommandChannel; m_subscriberID = clientID; m_keyIVs = null; m_cipherIndex = 0; CacheUpdateLock = new(); PendingCacheUpdateLock = new(); // Setup ping timer m_pingTimer = Common.TimerScheduler.CreateTimer(5000); m_pingTimer.AutoReset = true; m_pingTimer.Elapsed += PingTimer_Elapsed; m_pingTimer.Start(); // Setup reconnect timer m_reconnectTimer = Common.TimerScheduler.CreateTimer(1000); m_reconnectTimer.AutoReset = false; m_reconnectTimer.Elapsed += ReconnectTimer_Elapsed; LookupEndPointInfo(clientID, GetCommandChannelSocket().RemoteEndPoint as IPEndPoint, ref m_ipAddress, ref m_hostName, ref m_connectionID); }
private static double GetPublisherStatistic_ProcessedMeasurements(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = s_statisticValueCache.GetDifference(publisher, publisher.ProcessedMeasurements, "ProcessedMeasurements"); } return(statistic); }
private static double GetPublisherStatistic_ConnectedClientCount(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = publisher.Count; } return(statistic); }
public void OnDataPublisher(MessageArgument <T> arguments) { // Old way //var handler = DataPublisher; //if (handler != null) //{ // handler(this, arguments); //} // C# 6 way DataPublisher?.Invoke(this, arguments); }
private static double GetPublisherStatistic_UpTime(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = publisher.RunTime; } return(statistic); }
private static double GetPublisherStatistic_LifetimeBytesSent(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = publisher.TotalBytesSent; } return(statistic); }
/// <summary> /// Handles the confirmation message received from the /// subscriber to indicate that a buffer block was received. /// </summary> /// <param name="sequenceNumber">The sequence number of the buffer block.</param> /// <returns>A list of buffer block sequence numbers for blocks that need to be retransmitted.</returns> public void ConfirmBufferBlock(uint sequenceNumber) { DataPublisher parent = m_parent; int sequenceIndex; int removalCount; // We are still receiving confirmations, // so stop the retransmission timer m_bufferBlockRetransmissionTimer.Stop(); lock (m_bufferBlockCacheLock) { // Find the buffer block's location in the cache sequenceIndex = (int)(sequenceNumber - m_expectedBufferBlockConfirmationNumber); if (sequenceIndex >= 0 && sequenceIndex < m_bufferBlockCache.Count && (object)m_bufferBlockCache[sequenceIndex] != null) { // Remove the confirmed block from the cache m_bufferBlockCache[sequenceIndex] = null; if (sequenceNumber == m_expectedBufferBlockConfirmationNumber) { // Get the number of elements to trim from the start of the cache removalCount = m_bufferBlockCache.TakeWhile(m => (object)m == null).Count(); // Trim the cache m_bufferBlockCache.RemoveRange(0, removalCount); // Increase the expected confirmation number m_expectedBufferBlockConfirmationNumber += (uint)removalCount; } else { // Retransmit if confirmations are received out of order for (int i = 0; i < sequenceIndex; i++) { if ((object)m_bufferBlockCache[i] != null) { parent?.SendClientResponse(m_clientID, ServerResponse.BufferBlock, ServerCommand.Subscribe, m_bufferBlockCache[i]); OnBufferBlockRetransmission(); } } } } // If there are any objects lingering in the // cache, start the retransmission timer if (m_bufferBlockCache.Count > 0) { m_bufferBlockRetransmissionTimer.Start(); } } }
private static double GetPublisherStatistic_LifetimeAverageLatency(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = publisher.LifetimeAverageLatency; } return(statistic); }
private static double GetPublisherStatistic_AverageMeasurementsPerSecond(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = publisher.AverageMeasurementsPerSecond; } return(statistic); }
private static double GetPublisherStatistic_BufferBlockRetransmissions(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = s_statisticValueCache.GetDifference(publisher, publisher.BufferBlockRetransmissions, "BufferBlockRetransmissions"); } return(statistic); }
private void Start() { m_logger = new LogUtils.DebugLogger("Press"); m_state = PressState.Up; m_consumer = GetComponent <EnergyConsumer>(); m_animator = GetComponent <Animator>(); DataPublisher publisher = GetComponent <DataPublisher>(); m_pressPort = new DataPublisher.DataPort("IsPressed"); publisher.SetPort(m_pressPort); }
/// <summary> /// Creates a new <see cref="SynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> public SynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID) { // Pass parent reference into base class AssignParentCollection(parent); m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_signalIndexCache = new SignalIndexCache() { SubscriberID = subscriberID }; }
/// <summary> /// Creates a new <see cref="UnsynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> public UnsynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID) { m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_signalIndexCache = new SignalIndexCache(); m_signalIndexCache.SubscriberID = subscriberID; m_workingBuffer = new BlockAllocatedMemoryStream(); m_bufferBlockCache = new List <byte[]>(); m_bufferBlockCacheLock = new object(); }
/// <summary> /// Creates a new <see cref="SynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> /// <param name="compressionModes"><see cref="CompressionModes"/> requested by client.</param> public SynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID, CompressionModes compressionModes) { m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_compressionModes = compressionModes; m_signalIndexCache = new SignalIndexCache(); m_signalIndexCache.SubscriberID = subscriberID; m_bufferBlockCache = new List <byte[]>(); m_bufferBlockCacheLock = new object(); }
public DataPublisherTests(ITestOutputHelper output) : base(output) { // Fixture Setup var container = TestComponentryContainer.Create(output); this.barSerializer = new BarSerializer(); this.instrumentSerializer = new InstrumentSerializer(); this.publisher = new DataPublisher( container, DataBusFactory.Create(container), this.instrumentSerializer, new BypassCompressor(), EncryptionSettings.None(), new Port(55511)); }
private static double GetPublisherStatistic_TotalBytesSent(object source, string arguments) { double statistic = 0.0D; DataPublisher publisher = source as DataPublisher; if ((object)publisher != null) { statistic = s_statisticValueCache.GetDifference(publisher, publisher.TotalBytesSent, "TotalBytesSent"); if (statistic < 0.0D) { statistic = publisher.TotalBytesSent; } } return(statistic); }
public void RaiseDataProcessingExceptionOccurred() { var exception = new Exception(); string message = Guid.NewGuid().ToString(); EventHandler <ExceptionEventArgs> handler = null; handler = (s, e) => { DataPublisher.DataProcessingExceptionOccurred -= handler; Assert.AreSame(exception, e.Exception); Assert.AreEqual(message, e.Message); eventRaised = true; }; DataPublisher.DataProcessingExceptionOccurred += handler; DataPublisher.RaiseDataProcessExceptionOccurred(this, exception, message); EnqueueConditional(() => eventRaised); EnqueueTestComplete(); }
/// <summary> /// Creates a new <see cref="SubscriberAdapter"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> /// <param name="compressionModes"><see cref="CompressionModes"/> requested by client.</param> public SubscriberAdapter(DataPublisher parent, Guid clientID, Guid subscriberID, CompressionModes compressionModes) { m_parent = parent; ClientID = clientID; SubscriberID = subscriberID; m_compressionModes = compressionModes; m_bufferBlockCache = new(); m_bufferBlockCacheLock = new(); m_tsscSyncLock = new(); m_parent.ClientConnections.TryGetValue(ClientID, out m_connection); if (m_connection is null) { throw new NullReferenceException("Subscriber adapter failed to find associated connection"); } m_connection.SignalIndexCache = new() { SubscriberID = subscriberID }; }
/// <summary> /// Creates a new <see cref="UnsynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> public UnsynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID) { // Pass parent reference into base class AssignParentCollection(parent); m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_signalIndexCache = new SignalIndexCache() { SubscriberID = subscriberID }; m_processQueue = new AsyncQueue <IEnumerable <IMeasurement> >() { ProcessItemFunction = ProcessMeasurements }; m_processQueue.ProcessException += m_processQueue_ProcessException; }
/// <summary> /// Releases the unmanaged resources used by the <see cref="SynchronizedClientSubscription"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { // Remove reference to parent m_parent = null; // Dispose Iaon session this.DisposeTemporalSession(ref m_iaonSession); } } finally { m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
/// <summary> /// Creates a new <see cref="ClientConnection"/> instance. /// </summary> /// <param name="parent">Parent data publisher.</param> /// <param name="clientID">Client ID of associated connection.</param> /// <param name="commandChannel"><see cref="TcpServer"/> command channel used to lookup connection information.</param> public ClientConnection(DataPublisher parent, Guid clientID, TcpServer commandChannel) { m_parent = parent; m_clientID = clientID; m_commandChannel = commandChannel; m_subscriberID = clientID; m_keyIVs = null; m_cipherIndex = 0; // Setup ping timer m_pingTimer = new System.Timers.Timer(); m_pingTimer.Interval = 5000.0D; m_pingTimer.AutoReset = true; m_pingTimer.Elapsed += m_pingTimer_Elapsed; m_pingTimer.Start(); // Setup reconnect timer m_reconnectTimer = new System.Timers.Timer(); m_reconnectTimer.Interval = 1000.0D; m_reconnectTimer.AutoReset = false; m_reconnectTimer.Elapsed += m_reconnectTimer_Elapsed; // Attempt to lookup remote connection identification for logging purposes try { TransportProvider<Socket> client; IPEndPoint remoteEndPoint = null; if ((object)commandChannel != null && commandChannel.TryGetClient(clientID, out client)) remoteEndPoint = client.Provider.RemoteEndPoint as IPEndPoint; if ((object)remoteEndPoint != null) { m_ipAddress = remoteEndPoint.Address; if (remoteEndPoint.AddressFamily == AddressFamily.InterNetworkV6) m_connectionID = "[" + m_ipAddress + "]:" + remoteEndPoint.Port; else m_connectionID = m_ipAddress + ":" + remoteEndPoint.Port; try { IPHostEntry ipHost = Dns.GetHostEntry(remoteEndPoint.Address); if (!string.IsNullOrWhiteSpace(ipHost.HostName)) { m_hostName = ipHost.HostName; m_connectionID = m_hostName + " (" + m_connectionID + ")"; } } catch { // Just ignoring possible DNS lookup failures... } } } catch { // At worst we'll just use the client GUID for identification m_connectionID = (m_subscriberID == Guid.Empty ? clientID.ToString() : m_subscriberID.ToString()); } if (string.IsNullOrWhiteSpace(m_connectionID)) m_connectionID = "unavailable"; if (string.IsNullOrWhiteSpace(m_hostName)) { if (m_ipAddress != null) m_hostName = m_ipAddress.ToString(); else m_hostName = m_connectionID; } if (m_ipAddress == null) m_ipAddress = System.Net.IPAddress.None; }
private void OnDataPublisher(string args) { DataPublisher?.Invoke(this, args); }
/// <summary> /// Creates a new <see cref="ClientConnection"/> instance. /// </summary> /// <param name="parent">Parent data publisher.</param> /// <param name="clientID">Client ID of associated connection.</param> /// <param name="commandChannel"><see cref="TcpServer"/> command channel used to lookup connection information.</param> public ClientConnection(DataPublisher parent, Guid clientID, IServer commandChannel) { m_parent = parent; m_clientID = clientID; m_commandChannel = commandChannel; m_subscriberID = clientID; m_keyIVs = null; m_cipherIndex = 0; // Setup ping timer m_pingTimer = new Timer(); m_pingTimer.Interval = 5000.0D; m_pingTimer.AutoReset = true; m_pingTimer.Elapsed += m_pingTimer_Elapsed; m_pingTimer.Start(); // Setup reconnect timer m_reconnectTimer = new Timer(); m_reconnectTimer.Interval = 1000.0D; m_reconnectTimer.AutoReset = false; m_reconnectTimer.Elapsed += m_reconnectTimer_Elapsed; // Attempt to lookup remote connection identification for logging purposes try { Socket commandChannelSocket = GetCommandChannelSocket(); IPEndPoint remoteEndPoint = null; if ((object)commandChannel != null) remoteEndPoint = commandChannelSocket.RemoteEndPoint as IPEndPoint; if ((object)remoteEndPoint != null) { m_ipAddress = remoteEndPoint.Address; if (remoteEndPoint.AddressFamily == AddressFamily.InterNetworkV6) m_connectionID = "[" + m_ipAddress + "]:" + remoteEndPoint.Port; else m_connectionID = m_ipAddress + ":" + remoteEndPoint.Port; try { IPHostEntry ipHost = Dns.GetHostEntry(remoteEndPoint.Address); if (!string.IsNullOrWhiteSpace(ipHost.HostName)) { m_hostName = ipHost.HostName; m_connectionID = m_hostName + " (" + m_connectionID + ")"; } } // Just ignoring possible DNS lookup failures... catch (ArgumentNullException) { // The hostNameOrAddress parameter is null. } catch (ArgumentOutOfRangeException) { // The length of hostNameOrAddress parameter is greater than 255 characters. } catch (ArgumentException) { // The hostNameOrAddress parameter is an invalid IP address. } catch (SocketException) { // An error was encountered when resolving the hostNameOrAddress parameter. } } } catch { // At worst we'll just use the client GUID for identification m_connectionID = (m_subscriberID == Guid.Empty ? clientID.ToString() : m_subscriberID.ToString()); } if (string.IsNullOrWhiteSpace(m_connectionID)) m_connectionID = "unavailable"; if (string.IsNullOrWhiteSpace(m_hostName)) { if ((object)m_ipAddress != null) m_hostName = m_ipAddress.ToString(); else m_hostName = m_connectionID; } if ((object)m_ipAddress == null) m_ipAddress = IPAddress.None; }
/// <summary> /// Releases the unmanaged resources used by the <see cref="UnsynchronizedClientSubscription"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { m_parent = null; // Dispose base time rotation timer if ((object)m_baseTimeRotationTimer != null) { m_baseTimeRotationTimer.Dispose(); m_baseTimeRotationTimer = null; } // Dispose Iaon session this.DisposeTemporalSession(ref m_iaonSession); } } finally { m_disposed = true; // Prevent duplicate dispose. base.Dispose(disposing); // Call base class Dispose(). } } }
/// <summary> /// Creates a new <see cref="SynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> /// <param name="compressionModes"><see cref="CompressionModes"/> requested by client.</param> public SynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID, CompressionModes compressionModes) { m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_compressionModes = compressionModes; m_signalIndexCache = new SignalIndexCache(); m_signalIndexCache.SubscriberID = subscriberID; m_bufferBlockCache = new List<byte[]>(); m_bufferBlockCacheLock = new object(); }
/// <summary> /// Creates a new <see cref="UnsynchronizedClientSubscription"/>. /// </summary> /// <param name="parent">Reference to parent.</param> /// <param name="clientID"><see cref="Guid"/> based client connection ID.</param> /// <param name="subscriberID"><see cref="Guid"/> based subscriber ID.</param> public UnsynchronizedClientSubscription(DataPublisher parent, Guid clientID, Guid subscriberID) { // Pass parent reference into base class AssignParentCollection(parent); m_parent = parent; m_clientID = clientID; m_subscriberID = subscriberID; m_signalIndexCache = new SignalIndexCache() { SubscriberID = subscriberID }; m_processQueue = new AsyncQueue<IEnumerable<IMeasurement>>() { ProcessItemFunction = ProcessMeasurements }; m_processQueue.ProcessException += m_processQueue_ProcessException; }
/// <summary> /// Creates a new <see cref="ClientConnection"/> instance. /// </summary> /// <param name="parent">Parent data publisher.</param> /// <param name="clientID">Client ID of associated connection.</param> /// <param name="commandChannel"><see cref="TcpServer"/> command channel used to lookup connection information.</param> public ClientConnection(DataPublisher parent, Guid clientID, IServer commandChannel) { m_parent = parent; m_clientID = clientID; m_commandChannel = commandChannel; m_subscriberID = clientID; m_keyIVs = null; m_cipherIndex = 0; // Setup ping timer m_pingTimer = Common.TimerScheduler.CreateTimer(5000); m_pingTimer.AutoReset = true; m_pingTimer.Elapsed += m_pingTimer_Elapsed; m_pingTimer.Start(); // Setup reconnect timer m_reconnectTimer = Common.TimerScheduler.CreateTimer(1000); m_reconnectTimer.AutoReset = false; m_reconnectTimer.Elapsed += m_reconnectTimer_Elapsed; // Attempt to lookup remote connection identification for logging purposes try { Socket commandChannelSocket = GetCommandChannelSocket(); IPEndPoint remoteEndPoint = null; if ((object)commandChannel != null) { remoteEndPoint = commandChannelSocket.RemoteEndPoint as IPEndPoint; } if ((object)remoteEndPoint != null) { m_ipAddress = remoteEndPoint.Address; if (remoteEndPoint.AddressFamily == AddressFamily.InterNetworkV6) { m_connectionID = "[" + m_ipAddress + "]:" + remoteEndPoint.Port; } else { m_connectionID = m_ipAddress + ":" + remoteEndPoint.Port; } try { IPHostEntry ipHost = Dns.GetHostEntry(remoteEndPoint.Address); if (!string.IsNullOrWhiteSpace(ipHost.HostName)) { m_hostName = ipHost.HostName; m_connectionID = m_hostName + " (" + m_connectionID + ")"; } } // Just ignoring possible DNS lookup failures... catch (ArgumentNullException) { // The hostNameOrAddress parameter is null. } catch (ArgumentOutOfRangeException) { // The length of hostNameOrAddress parameter is greater than 255 characters. } catch (ArgumentException) { // The hostNameOrAddress parameter is an invalid IP address. } catch (SocketException) { // An error was encountered when resolving the hostNameOrAddress parameter. } } } catch { // At worst we'll just use the client GUID for identification m_connectionID = m_subscriberID == Guid.Empty ? clientID.ToString() : m_subscriberID.ToString(); } if (string.IsNullOrWhiteSpace(m_connectionID)) { m_connectionID = "unavailable"; } if (string.IsNullOrWhiteSpace(m_hostName)) { if ((object)m_ipAddress != null) { m_hostName = m_ipAddress.ToString(); } else { m_hostName = m_connectionID; } } if ((object)m_ipAddress == null) { m_ipAddress = IPAddress.None; } }
/// <summary> /// Handles publish data, if the handler is not null /// </summary> /// <param name="args"></param> private void OnDataPublisher(MessageArgument <T> args) { DataPublisher?.Invoke(this, args); }