<commit_before>using System;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using StompSharp.Messages;

namespace StompSharp.Transport
{
    public class StompTransport : ITransport
    {
        private readonly Subject<IMessage> _incommingMessagesSubject = new Subject<IMessage>();
        private readonly Subject<IMessage> _outgoingMessagesSubject = new Subject<IMessage>();
        private readonly TcpClient _client;
        private readonly IMessageFactory _messageFactory;
        private readonly IMessageSerializer _messageSerializer;
        private bool _disposed;
        private readonly IMessageRouter _incommingMessageRouter;

        public StompTransport(string address, int port)
        {
            _client = new TcpClient();
            _client.Connect(address, port);

            _messageFactory = new StreamMessageFactory(new StreamReader(_client.GetStream(), Encoding.ASCII));
            _messageSerializer =
                 new MessageSerializerQueue(
                    new StreamMessageSerializer(new StreamWriter(_client.GetStream(), Encoding.ASCII)));

            _incommingMessageRouter = new MessageRouter(_incommingMessagesSubject);

            Task.Factory.StartNew(ReadLoop);

            using (var lateSubscriber = new LateSubscriber<IMessage>(IncommingMessages.GetObservable("CONNECTED")))
            {
                SendMessage(new MessageBuilder("CONNECT").Header("accept-version", 1.2).WithoutBody()).Wait();

                lateSubscriber.RecordedItems.FirstAsync().Wait();
            }
        }

        private async void ReadLoop()
        {
            try
            {
                while (!_disposed)
                {
                    _incommingMessagesSubject.OnNext(await _messageFactory.Create());
                }
            }
            catch (Exception)
            {
                if (_disposed)<commit_msg>Moved to 8 bit ASCII encoding (CodePage 437)<commit_after>using System;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using StompSharp.Messages;

namespace StompSharp.Transport
{
    public class StompTransport : ITransport
    {
        private static readonly Encoding ASCII8BitEncoding = Encoding.GetEncoding(437);

        private readonly Subject<IMessage> _incommingMessagesSubject = new Subject<IMessage>();
        private readonly Subject<IMessage> _outgoingMessagesSubject = new Subject<IMessage>();
        private readonly TcpClient _client;
        private readonly IMessageFactory _messageFactory;
        private readonly IMessageSerializer _messageSerializer;
        private bool _disposed;
        private readonly IMessageRouter _incommingMessageRouter;

        public StompTransport(string address, int port)
        {
            _client = new TcpClient();
            _client.Connect(address, port);

            _messageFactory = new StreamMessageFactory(new StreamReader(_client.GetStream(), ASCII8BitEncoding));
            _messageSerializer =
                 new MessageSerializerQueue(
                    new StreamMessageSerializer(new StreamWriter(_client.GetStream(), ASCII8BitEncoding)));

            _incommingMessageRouter = new MessageRouter(_incommingMessagesSubject);

            Task.Factory.StartNew(ReadLoop);

            using (var lateSubscriber = new LateSubscriber<IMessage>(IncommingMessages.GetObservable("CONNECTED")))
            {
                SendMessage(new MessageBuilder("CONNECT").Header("accept-version", 1.2).WithoutBody()).Wait();

                lateSubscriber.RecordedItems.FirstAsync().Wait();
            }
        }

        private async void ReadLoop()
        {
            try
            {
                while (!_disposed)
                {
                    _incommingMessagesSubject.OnNext(await _messageFactory.Create());
                }
            }
            catch (Exception)
            {
                if (_disposed)
{'fraction_non_alphanumeric': 0.07883317261330762, 'fraction_numerical': 0.0033751205400192863, 'mean_word_length': 2.4719665271966527, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6597884', 'n_tokens_mistral': 1023, 'n_tokens_neox': 981, 'n_words': 218}