/// <summary> /// Prepis a rozsirenie prijatia / akceptovania klienta /// </summary> /// <param name="e">TcpClientEventArgs</param> protected override void OnTcpClientReceived(TcpClientEventArgs e) { //base volanie na vytvorenie eventu base.OnTcpClientReceived(e); //overime ci je mozne pridat dalsieho klienta if (this.InternalCheckContracts()) { try { //pridame instaniu servera ITransportClient contract = this.InternalCreateContract(e.Client); //validate contract if (contract != null && contract.IsConnected) { //namapujeme event oznamujuci odhlasenie klienta contract.DisconnectedEvent += new EventHandler(contract_DisconnectedEvent); //pridame contract this.InternalCreateContract(contract); //create event about new client this.OnTransportClientAdded(new TransportClientEventArgs(contract)); } else { //ukoncime inicializovany contract if (contract != null) { contract.Dispose(); contract = null; } } } catch (Exception ex) { //chybu ignorujeme this.InternalTrace(TraceTypes.Error, "Interna chyba pri udalostiach spojenych z pridavanim pripojeneho klienta. {0}", ex.Message); } } else { try { //zalogujeme this.InternalTrace(TraceTypes.Verbose, "Ukoncovanie akceptovaneho klienta..."); //ziskame pristup TcpClient client = e.Client; client.Close(); } catch (Exception) { //ignorujeme } } }
/// <summary> /// Vygeneruje event oznamujuci prijatie xml dokumentu /// </summary> /// <param name="e">XmlDocumentEventArgs</param> protected virtual void OnTcpClientReceived(TcpClientEventArgs e) { TcpClientEventHandler handler = this.m_tcpClientReceivedEvent; if (handler != null) { handler(this, e); } }