diff --git a/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.csproj b/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.csproj index bb0d762..61e08e3 100644 --- a/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.csproj +++ b/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1;net471 + netcoreapp3.1;net48 false @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs b/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs index 216d280..f2dfb2b 100644 --- a/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs +++ b/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs @@ -10,6 +10,32 @@ using System.Threading.Tasks; namespace Capnp.Rpc { + /// + /// State of Variable has changed + /// + public delegate void StateChanged(); + + /// + /// ConnectionState has changed EventArgs + /// + public class ConnectionStateEventArgs : EventArgs + { + /// + /// New State of Connection + /// + public ConnectionState NewState { get; set; } + + /// + /// Last State of Connection + /// + public ConnectionState LastState { get; set; } + } + + /// + /// ConnectionState EventHandler + /// + public delegate void ConnectionStateEventHandler(Object sender, ConnectionStateEventArgs e); + /// /// TCP-based RPC implementation which will establish a connection to a TCP server implementing /// the Cap'n Proto RPC protocol. @@ -131,11 +157,17 @@ namespace Capnp.Rpc /// /// Constructs an instance but does not yet attempt to connect. /// - public TcpRpcClient() + /// The time-out value of the connection in milliseconds. + /// The send time-out value, in milliseconds. + public TcpRpcClient(int receiveTimeout = 0, int sendTimeout = 0) { _rpcEngine = new RpcEngine(); - _client = new TcpClient(); - _client.ExclusiveAddressUse = false; + _client = new TcpClient + { + ExclusiveAddressUse = false, + ReceiveTimeout = receiveTimeout, + SendTimeout = sendTimeout + }; } /// @@ -250,10 +282,41 @@ namespace Capnp.Rpc _client.Dispose(); } + /// + /// State of Connection has changed + /// + public event ConnectionStateEventHandler? ConnectionStateChanged; + + /// + /// On ConnectionState changed + /// + protected virtual void OnConnectionStateChanged(ConnectionStateEventArgs e) + { + ConnectionStateChanged?.Invoke(this, e); + } + + private ConnectionState _State = ConnectionState.Initializing; + /// /// Returns the state of this connection. /// - public ConnectionState State { get; private set; } = ConnectionState.Initializing; + public ConnectionState State { + get + { + return _State; + } + private set + { + ConnectionStateEventArgs args = new ConnectionStateEventArgs() + { + LastState = _State, + NewState = value + }; + _State = value; + + OnConnectionStateChanged(args); + } + } /// /// Gets the number of RPC protocol messages sent by this client so far. diff --git a/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj b/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj index fa65489..62749ce 100644 --- a/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj +++ b/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp2.1 + netstandard2.0;netcoreapp3.1; Debug;Release true true diff --git a/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs b/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs index dc48beb..0622bd9 100644 --- a/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs +++ b/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs @@ -184,6 +184,6 @@ /// /// Generator tool version for GeneratedCodeAttribute /// - public string GeneratorToolVersion = ThisAssembly.AssemblyVersion; + public string GeneratorToolVersion = "0.0"; } } diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj index 605d405..6552ebd 100644 --- a/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj @@ -1,6 +1,6 @@  - net471;netcoreapp2.1 + net48;netcoreapp3.1 false true