Exemple #1
0
        public RxSocket(ISocket socket, IParser parser, IMessageFormatter <TPayload> formatter)
        {
            _socket    = socket;
            _parser    = parser;
            _formatter = formatter;

            _socket.WhenMessageParsed.Subscribe(bytes => _formatter.FormatMessageAsync(bytes));
            _whenMessageReceived = new Subject <TPayload>();
            _whenMessageSent     = new Subject <TPayload>();
            _factoryScheduler    = new TaskPoolScheduler(Task.Factory);
            _formatter.WhenNewMessage.Subscribe(message => _whenMessageReceived.OnNext(message));
        }