예제 #1
0
        public async Task ConnectAsync(Stream stream, CancellationToken cancellationToken = default)
        {
            if (this.IsConnected == true)
            {
                throw Assert.Exception(new InvalidOperationException("Connection has already been made."));
            }

            IMessageTransmitter messageTransmitter = this.SerializationProvider.CreateMessageTransmitter(stream);

            try
            {
                await this.DialogProvider.ConnectAsync(messageTransmitter, cancellationToken);

                this.IsConnected = true;
            }catch
            {
                messageTransmitter.Dispose();

                throw;
            }
        }
예제 #2
0
        public void Connect(Stream stream)
        {
            if (this.IsConnected == true)
            {
                throw Assert.Exception(new InvalidOperationException("Connection has already been made."));
            }

            IMessageTransmitter messageTransmitter = this.SerializationProvider.CreateMessageTransmitter(stream);

            try
            {
                this.DialogProvider.Connect(messageTransmitter);

                this.IsConnected = true;
            }catch
            {
                messageTransmitter.Dispose();

                throw;
            }
        }