internal void DataReceivedEvent(TelnetNVT client, string text) { if (OnDataReceived != null) OnDataReceived(client, text); }
internal void RemoveClient(TelnetNVT client) { m_pendingRemoval.Add(client); }
public void Update() { if (m_server == null) return; IEnumerator<KeyValuePair<int, TelnetNVT>> it = m_activeClients.GetEnumerator(); while (it.MoveNext()) it.Current.Value.Update(); if (m_server.Pending()) { TcpClient client = m_server.AcceptTcpClient(); Log.Info("Client connected from ", client.Client.RemoteEndPoint.ToString()); TelnetNVT telnetClient = new TelnetNVT(this, client, m_clientId++); telnetClient.Start(); m_activeClients.Add(telnetClient.Id, telnetClient); if (OnClientConnected != null) OnClientConnected(telnetClient); } if (m_pendingRemoval.Count > 0) { for (int i = 0; i < m_pendingRemoval.Count; i++) { var client = m_pendingRemoval[i]; m_activeClients.Remove(client.Id); client.Stop(); if (OnClientDisconnected != null) OnClientDisconnected(client); } m_pendingRemoval.Clear(); } }