diff --git a/libnpsharp.userprefs b/libnpsharp.userprefs new file mode 100644 index 0000000..337b019 --- /dev/null +++ b/libnpsharp.userprefs @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/libnpsharp/NpClient.cs b/src/libnpsharp/NpClient.cs index 4bb76cc..d1dfa6a 100644 --- a/src/libnpsharp/NpClient.cs +++ b/src/libnpsharp/NpClient.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using NPSharp.Rpc; using NPSharp.Rpc.Packets; +using log4net; namespace NPSharp { @@ -17,6 +18,7 @@ namespace NPSharp private readonly RpcClientStream _rpc; private CancellationTokenSource _cancellationTokenSource; private CancellationToken _cancellationToken; + private ILog _log; /// /// Initializes the NP client with a specified host and port. @@ -26,6 +28,7 @@ namespace NPSharp public NpClient(string host, ushort port = 3025) { _rpc = new RpcClientStream(host, port); + _log = LogManager.GetLogger ("NPClient"); } /// @@ -53,8 +56,7 @@ namespace NPSharp Task.Factory.StartNew(() => { - Debug.WriteLine("Processing thread start"); - + _log.Debug("Now receiving RPC messages"); try { while (true) @@ -69,10 +71,11 @@ namespace NPSharp } catch (ProtocolViolationException error) { - Console.WriteLine("Protocol violation: {0}. Disconnect imminent.", error.Message); + _log.ErrorFormat("Protocol violation: {0}. Disconnect imminent.", error.Message); + Disconnect(); } - Debug.WriteLine("Processing thread exit"); + _log.Debug("Now not receiving RPC messages anymore"); }, _cancellationToken); return true; diff --git a/src/libnpsharp/libnpsharp.csproj b/src/libnpsharp/libnpsharp.csproj index 5478e05..d953e3a 100644 --- a/src/libnpsharp/libnpsharp.csproj +++ b/src/libnpsharp/libnpsharp.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,6 +12,8 @@ v4.5 512 + 12.0.0 + 2.0 true @@ -33,9 +35,6 @@ false - - ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - @@ -43,6 +42,12 @@ + + ..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + + ..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll + @@ -67,9 +72,6 @@ - - - - \ No newline at end of file + + + + + + + diff --git a/src/libnpsharp/packages.config b/src/libnpsharp/packages.config index 0cd8e89..6c0fa8f 100644 --- a/src/libnpsharp/packages.config +++ b/src/libnpsharp/packages.config @@ -1,4 +1,5 @@ - - - + + + + \ No newline at end of file