aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/ITransportAdapter.cs
blob: 3c5bed9d01448358199f7f7bd1cac8ca571e2bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Transport
{
    /// <summary>
    /// Represents a transport adapter capable of connecting, writing and receiving data from a stream.
    /// </summary>
    /// <seealso cref="Tango.Transport.ITransportComponent" />
    public interface ITransportAdapter : ITransportComponent, INotifyPropertyChanged
    {
        /// <summary>
        /// Gets the last failed state exception/reason.
        /// </summary>
        Exception FailedStateException { get; }

        /// <summary>
        /// Gets the total bytes received.
        /// </summary>
        long TotalBytesReceived { get; }

        /// <summary>
        /// Gets the total bytes sent.
        /// </summary>
        long TotalBytesSent { get; }

        /// <summary>
        /// Gets the adapter current transfer rate.
        /// </summary>
        long TransferRate { get; }

        /// <summary>
        /// Gets or sets a value indicating whether to enable compression/decompression of data.
        /// </summary>
        bool EnableCompression { get; set; }

        /// <summary>
        /// Writes the specified data to the stream.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="immidiate">Writes the data as soon as possible while ignoring any message queuing and batching.</param>
        void Write(byte[] data, bool immidiate = false);

        /// <summary>
        /// Occurs when new data is available.
        /// </summary>
        event EventHandler<byte[]> DataAvailable;

        /// <summary>
        /// Gets or sets the adapter address.
        /// </summary>
        String Address { get; set; }
    }
}