コード例 #1
0
        public void StartConnection(TcpConnectionSettings connectionSettings)
        {
            if (this.State == WorkingState.Enabled)
            {
                _logger.UpdateLog("TCP connection starting aborted - connection is already enabled!");
                return;
            }

            _connectionSettings = connectionSettings;

            try
            {
                ConnectionData connData = connectionSettings.ToConnectionData();
                //TcpServer.SetContainerSize(5);
                _tcpServerInstance = TcpServer.RunServer(connData, _logger);
                this.State         = WorkingState.Enabled;

                HandleClientCommandsAsync();
                HandleClientActivityCheckAsync();
            }
            catch (Exception exception)
            {
                _logger.UpdateLog($"TCP connection - connection starting error: {exception.Message}");
                this.State = WorkingState.Error;
            }
        }
コード例 #2
0
        public void StartConnection(TcpConnectionSettings connectionSettings)
        {
            _connectionSettings = connectionSettings;
            _logger.UpdateLog($"Starting connection with IP [{connectionSettings.Ip}] port [{connectionSettings.Port}]");

            try
            {
                ConnectionData connData = connectionSettings.ToConnectionData();
                //TcpServerClient.SetCommandInsertionTimeLimit(15);
                _tcpClientInstance = TcpServerClient.RunServerClient(connData, _logger);
                this.State         = WorkingState.Enabled;

                HandleServerCommandsAsync();
            }
            catch (Exception exception)
            {
                _logger.UpdateLog($"TCP connection - connection starting error: {exception.Message} | {exception.StackTrace}");
                this.State = WorkingState.Error;
            }
        }