예제 #1
0
        private void MessageBuilder()
        {
            Boolean threadOk = true;

            while (_connected && threadOk)
            {
                if (_messageBuilderThreadTokenSource.IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    byte[]     lengthInformation = _buffer.getFromStart(4);
                    long       messageDataLength = HTSMessage.uIntToLong(lengthInformation[0], lengthInformation[1], lengthInformation[2], lengthInformation[3]);
                    byte[]     messageData       = _buffer.extractFromStart((int)messageDataLength + 4); // should be long !!!
                    HTSMessage response          = HTSMessage.parse(messageData, _logger);

                    ProcessResponse(response);
                }
                catch (Exception ex)
                {
                    threadOk = false;
                    _logger.ErrorException("[TVHclient] MessageBuilder caught exception : {0} but no error listener is configured!!!", ex, ex.ToString());
                }
            }
        }
        private void MessageBuilder()
        {
            Boolean threadOk = true;

            while (_connected && threadOk)
            {
                if (_messageBuilderThreadTokenSource.IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    byte[]     lengthInformation = _buffer.getFromStart(4);
                    long       messageDataLength = HTSMessage.uIntToLong(lengthInformation[0], lengthInformation[1], lengthInformation[2], lengthInformation[3]);
                    byte[]     messageData       = _buffer.extractFromStart((int)messageDataLength + 4); // should be long !!!
                    HTSMessage response          = HTSMessage.parse(messageData, _loggerFactory.CreateLogger <HTSMessage>());
                    _receivedMessagesQueue.Enqueue(response);
                }
                catch (Exception ex)
                {
                    threadOk = false;
                    if (_listener != null)
                    {
                        _listener.onError(ex);
                    }
                    else
                    {
                        _logger.LogError(ex, "[TVHclient] HTSConnectionAsync.MessageBuilder: exception caught, but no error listener is configured");
                    }
                }
            }
        }
예제 #3
0
        private void MessageBuilder()
        {
            Boolean threadOk = true;

            while (_connected && threadOk)
            {
                try
                {
                    byte[]     lengthInformation = _buffer.getFromStart(4);
                    long       messageDataLength = HTSMessage.uIntToLong(lengthInformation[0], lengthInformation[1], lengthInformation[2], lengthInformation[3]);
                    byte[]     messageData       = _buffer.extractFromStart((int)messageDataLength + 4); // should be long !!!
                    HTSMessage response          = HTSMessage.parse(messageData, _logger);
                    _receivedMessagesQueue.Enqueue(response);
                }
                catch (ThreadAbortException)
                {
                    threadOk = false;
                    Thread.ResetAbort();
                }
                catch (Exception ex)
                {
                    if (_listener != null)
                    {
                        _listener.onError(ex);
                    }
                    else
                    {
                        _logger.ErrorException("[TVHclient] MessageBuilder caught exception : {0} but no error listener is configured!!!", ex, ex.ToString());
                    }
                }
            }
        }