/// <summary> /// Broadcast an error message to all /// the connected clients with the Monitor /// flag enabled /// </summary> /// <param name="message"></param> private void BroadcastMonitorAck(string message) { if (_watsonTcpServer != null) { foreach (var type in _messageTypes) { var messageType = $"[{type}]"; if (message.IndexOf(messageType) == 0) { _messageHeap = messageType; return; } } if (_messageHeap != string.Empty) { message = _messageHeap + message; _messageHeap = string.Empty; } var users = Guard.GetAuthUsers(); foreach (var user in users) { if (user.Monitor && _watsonTcpServer.IsClientConnected(user.IpPort)) { Send(user, new ServerMonitorAck() { Output = message }); } } } }
internal bool IsConnected(string ipPort) { if (_WtcpServer == null) { Logger?.Invoke("[ClusterServer] Server is null"); return(false); } if (String.IsNullOrEmpty(ipPort)) { return(false); } return(_WtcpServer.IsClientConnected(ipPort)); }
/// <summary> /// Determines if a specified client is connected to the local server. /// </summary> /// <returns>True if connected.</returns> internal bool IsConnected(string ipPort) { if (_WtcpServer == null) { if (Debug) { Console.WriteLine("Server is null"); } return(false); } if (String.IsNullOrEmpty(ipPort)) { return(false); } return(_WtcpServer.IsClientConnected(ipPort)); }
/// <summary> /// Al conectarse un cliente TCP al servidor /// </summary> /// <param name="ipPort">IP:Puerto</param> private bool TcpServer_OnNodeConnected(string ipPort) { if (m_connectedRootNode != null) { if (m_killOnConnect) { m_tcpServer.DisconnectClient(m_connectedRootNode); m_connectedRootNode = null; } else { if (!m_tcpServer.IsClientConnected(m_connectedRootNode)) { m_connectedRootNode = null; } } } if (m_connectedRootNode == null) { m_connectedRootNode = ipPort; Debug.WriteLine(this, "Se ha conectado un nodo raíz al servidor TCP para MDF: " + ipPort, VerbosityLevel.Info); } else { m_tcpServer.DisconnectClient(ipPort); Debug.WriteLine(this, "Se ha intentado conectar un nuevo nodo raíz al servidor TCP mientras que ya habia uno registrado, se ha desconectado la nueva conexión: " + ipPort, VerbosityLevel.Warning); } return(true); }