Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public LoggingClientSocket
        (
            [NotNull] IrbisConnection connection,
            [NotNull] AbstractClientSocket innerSocket,
            [NotNull] string debugPath
        )
            : base(connection)
        {
            Sure.NotNull(innerSocket, nameof(innerSocket));
            Sure.NotNullNorEmpty(debugPath, nameof(debugPath));

            if (!Directory.Exists(debugPath))
            {
                throw new IrbisNetworkException
                      (
                          "directory not exist: " + debugPath
                      );
            }

            DebugPath   = debugPath;
            InnerSocket = innerSocket;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send request to server and receive answer.
        /// </summary>
        public override byte[] ExecuteRequest
        (
            byte[] request
        )
        {
            Sure.NotNull(request, "request");

            AbstractClientSocket innerSocket = InnerSocket
                                               .ThrowIfNull("InnerSocket");

            byte[] result;
            try
            {
                result = innerSocket.ExecuteRequest(request);
            }
            catch (Exception exception)
            {
                Log.TraceException
                (
                    "LoggingClientSocket::ExecuteRequest",
                    exception
                );

                Task.Factory.StartNew
                (
                    () => _DumpException(exception)
                );
                throw;
            }

            Task.Factory.StartNew
            (
                () => _DumpPackets(request, result)
            );

            return(result);
        }