示例#1
0
        public async Task Connect_SetsIdAndName()
        {
            _rtm.Connect().Returns(new ConnectResponse {
                Self = new Self {
                    Id = "foo", Name = "bar"
                }
            });

            await _sut.Connect();

            _sut.Id.ShouldBe("foo");
            _sut.Name.ShouldBe("bar");
        }
示例#2
0
        /// <summary>
        /// Connect to Slack.
        /// </summary>
        public async Task Connect(CancellationToken?cancellationToken = null)
        {
            // If already connected, client will throw
            var connection = _rtm.Connect(cancellationToken: cancellationToken);

            _incomingSubscription = _incomingWithMiddlewareApplied
                                    .Subscribe(HandleMessage);
            _outgoingSubscription = _outgoingWithMiddlewareApplied
                                    .SelectMany(PostMessage)
                                    .Retry()
                                    .Subscribe();

            var connectResponse = await connection.ConfigureAwait(false);

            Id   = connectResponse.Self.Id;
            Name = connectResponse.Self.Name;
        }
示例#3
0
        /// <summary>
        /// Connect to Slack.
        /// </summary>
        public async Task Connect(CancellationToken?cancellationToken = null)
        {
            // If already connected, client will throw
            var connection = _rtm.Connect(cancellationToken: cancellationToken);

            _incomingSubscription = _incomingWithMiddlewareApplied
                                    .Subscribe(HandleMessage);
            _sentMessages = _outgoingWithMiddlewareApplied
                            .Select(m => new PostedMessage {
                Message = m, Post = PostMessage(m)
            })
                            .Retry()
                            .Publish()
                            .RefCount();
            _outgoingSubscription = _sentMessages.Subscribe();

            var connectResponse = await connection.ConfigureAwait(false);

            Id   = connectResponse.Self.Id;
            Name = connectResponse.Self.Name;
        }