/// <summary> /// Sends the specified event to all connected clients. /// The information is only sent to those clients who have previously subscribed to this event type /// </summary> /// <param name="type">Types of the event that has occurred.</param> /// <param name="code">Type of the protocol message being sent.</param> /// <param name="data">Byte-field of the data, appropriate for the specific `code` used.</param> /// <param name="address">Ixian Wallet Address which triggered the event</param> /// <param name="helper_data">Optional, additional data to transmit after `data`.</param> /// <param name="skipEndpoint">If given, the message will not be sent to this remote endpoint. This prevents echoing the message to the originating node.</param> /// <returns>True, if at least one message was sent to at least one client.</returns> public static bool broadcastEventData(NetworkEvents.Type type, ProtocolMessageCode code, byte[] data, byte[] address, byte[] helper_data, RemoteEndpoint skipEndpoint = null) { bool result = false; try { lock (connectedClients) { foreach (RemoteEndpoint endpoint in connectedClients) { if (skipEndpoint != null) { if (endpoint == skipEndpoint) { continue; } } if (!endpoint.isConnected()) { continue; } if (endpoint.helloReceived == false) { continue; } if (endpoint.presenceAddress == null || endpoint.presenceAddress.type != 'C') { continue; } // Finally, check if the endpoint is subscribed to this event and address if (endpoint.isSubscribedToEvent(type, address)) { endpoint.sendData(code, data, helper_data); result = true; } } } }catch (Exception e) { Logging.error("Exception occured in NetworkServer.broadcastEventData: " + e); } return(result); }