mirror of https://github.com/icedream/npsharp.git
Logging via log4net.
parent
11be50dd4c
commit
e536b3a114
|
@ -0,0 +1,13 @@
|
|||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="src/libnpsharp/NpClient.cs">
|
||||
<Files>
|
||||
<File FileName="src/libnpsharp/Rpc/Packets/AuthenticateExternalStatusMessage.cs" Line="1" Column="1" />
|
||||
<File FileName="src/libnpsharp/NpClient.cs" Line="31" Column="45" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
</Properties>
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -12,6 +12,8 @@
|
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<ProductVersion>12.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -33,9 +35,6 @@
|
|||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="protobuf-net">
|
||||
<HintPath>..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
@ -43,6 +42,12 @@
|
|||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="protobuf-net">
|
||||
<HintPath>..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NpClient.cs" />
|
||||
|
@ -67,9 +72,6 @@
|
|||
<Compile Include="Rpc\Packets\StorageWriteUserFileResultMessage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -79,4 +81,10 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Authentication\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="protobuf-net" version="2.0.0.668" targetFramework="net40" />
|
||||
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||
<package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue