Skip to content

Commit

Permalink
Merge pull request #1 from l0nley/master
Browse files Browse the repository at this point in the history
Framework update
  • Loading branch information
genemars authored Mar 28, 2020
2 parents b8b5f9a + eafe15e commit f1aa6d5
Show file tree
Hide file tree
Showing 39 changed files with 349 additions and 645 deletions.
27 changes: 0 additions & 27 deletions Test.UPnP/Properties/AssemblyInfo.cs

This file was deleted.

54 changes: 10 additions & 44 deletions Test.UPnP/Test.UPnP.csproj
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B2674788-A4F4-477B-90B6-A3B6E552DBEB}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Test.UPnP</RootNamespace>
<AssemblyName>Test.UPnP</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\UPnP\UPnP.csproj">
<Project>{584ED187-8F2A-4B58-A266-85F3F212B092}</Project>
<Name>UPnP</Name>
</ProjectReference>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\UPnP\UPnP.csproj" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Test.UPnP/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
Binary file added UPnP/.vs/UPnP/DesignTimeBuild/.dtbcache
Binary file not shown.
Empty file.
Binary file added UPnP/.vs/UPnP/v16/Server/sqlite3/storage.ide
Binary file not shown.
4 changes: 3 additions & 1 deletion UPnP/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.InteropServices;
using System.Reflection;
using System.Runtime.CompilerServices;

Expand Down Expand Up @@ -26,7 +27,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down Expand Up @@ -54,3 +55,4 @@
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: ComVisible(false)]
10 changes: 5 additions & 5 deletions UPnP/AsyncSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void AddMembership(IPEndPoint local, IPAddress MulticastAddress)
catch (Exception ex)
{
OpenSource.Utilities.EventLogger.Log(ex);
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Cannot AddMembership to IPAddress: " + MulticastAddress.ToString());
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Cannot AddMembership to IPAddress: " + MulticastAddress.ToString());
}
try
{
Expand All @@ -312,7 +312,7 @@ public void AddMembership(IPEndPoint local, IPAddress MulticastAddress)
catch (Exception ex)
{
OpenSource.Utilities.EventLogger.Log(ex);
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Cannot Set Multicast Interface to IPAddress: " + local.Address.ToString());
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Cannot Set Multicast Interface to IPAddress: " + local.Address.ToString());
}
}

Expand Down Expand Up @@ -638,7 +638,7 @@ public void Send(Byte[] buffer, int offset, int length, IPEndPoint dest, object
catch (Exception ex)
{
OpenSource.Utilities.EventLogger.Log(ex);
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Send Failure [Normal for non-pipelined connection]");
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Send Failure [Normal for non-pipelined connection]");
Disconnect = true;
}
}
Expand Down Expand Up @@ -714,7 +714,7 @@ private void HandleSend(IAsyncResult result)
catch (Exception ex)
{
OpenSource.Utilities.EventLogger.Log(ex);
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Send Failure [Normal for non-pipelined connection]");
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Send Failure [Normal for non-pipelined connection]");
Disconnect = true;
}
}
Expand Down Expand Up @@ -798,7 +798,7 @@ private void HandleReceive(IAsyncResult result)
return;
}

// OpenSource.Utilities.EventLogger.Log(this,System.Diagnostics.EventLogEntryType.Information,"BytesRead: " + BytesReceived.ToString() + " BytesRequested: "+this.BufferReadLength.ToString());
// OpenSource.Utilities.EventLogger.Log(this,EventLogEntryType.Information,"BytesRead: " + BytesReceived.ToString() + " BytesRequested: "+this.BufferReadLength.ToString());

if (BytesReceived <= 0)
{
Expand Down
44 changes: 27 additions & 17 deletions UPnP/EventLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ namespace OpenSource.Utilities
/// system log file upon startup. All exceptions should be sent to the log
/// using the Log(Exception) method.
/// </summary>
///

public enum EventLogEntryType {
Error,
FailureAudit,
Information,
SuccessAudit,
}


public sealed class EventLogger
{
public delegate void EventHandler(EventLogEntryType LogType, object origin, string StackTrace, string LogMessage);
// public delegate void EventHandler(EventLogEntryType LogType, object origin, string StackTrace, string LogMessage);

public static event EventHandler OnEvent;
//public static event EventHandler OnEvent;

public static bool Enabled = false;
public static bool ShowAll = false;
Expand All @@ -39,7 +49,7 @@ public sealed class EventLogger
private static string g_sourceName = null;
private static string g_productVersion = null;
private static bool g_onExceptionShowMessage = false;
private static EventLog log = null;
private static dynamic log = null;

/// <summary>
/// Set the application wide event logging to a Windows event log file.
Expand All @@ -49,7 +59,7 @@ public sealed class EventLogger
/// <param name="productVersion">The application's version string</param>
public static void SetLog(string sourceName, string logName, string productVersion)
{
try
/* try
{
g_logName = logName;
g_sourceName = sourceName;
Expand All @@ -62,7 +72,7 @@ public static void SetLog(string sourceName, string logName, string productVersi
catch (Exception)
{
StopLog();
}
}*/
}

/// <summary>
Expand All @@ -73,15 +83,15 @@ public static void SetLog(string sourceName, string logName, string productVersi
/// <param name="showMessageBox">Show a message box with the event</param>
public static void SetOnExceptionAction(bool showMessageBox)
{
g_onExceptionShowMessage = showMessageBox;
/*g_onExceptionShowMessage = showMessageBox;*/
}

/// <summary>
/// Stop application wide logging
/// </summary>
public static void StopLog()
{
try
/*try
{
Enabled = false;
if (log != null)
Expand All @@ -93,7 +103,7 @@ public static void StopLog()
}
catch (Exception)
{
}
}*/
}

/// <summary>
Expand All @@ -102,7 +112,7 @@ public static void StopLog()
/// <param name="information">Information string to be logged</param>
public static void Log(string information)
{
Log(new object(), EventLogEntryType.Information, information);
/*Log(new object(), EventLogEntryType.Information, information);*/
}

public static void Log(object sender, EventLogEntryType LogType, string information)
Expand All @@ -111,7 +121,7 @@ public static void Log(object sender, EventLogEntryType LogType, string informat
{
sender = new object();
}
if (Enabled)
/*if (Enabled)
{
if (ShowAll == true || LogType == EventLogEntryType.Error || LogType == EventLogEntryType.SuccessAudit)
{
Expand Down Expand Up @@ -152,10 +162,10 @@ public static void Log(object sender, EventLogEntryType LogType, string informat
}
}
}
if (OnEvent != null)
OnEvent(LogType, sender, trace.ToString(), information);
*//*if (OnEvent != null)
OnEvent(LogType, sender, trace.ToString(), information);*//*
}
}
}*/
}

public static void Log(Exception exception)
Expand All @@ -169,7 +179,7 @@ public static void Log(Exception exception)
/// <param name="exception">Exception to be logged</param>
public static void Log(Exception exception, string additional)
{
try
/* try
{
string name = exception.GetType().FullName;
string message = exception.Message;
Expand Down Expand Up @@ -203,7 +213,7 @@ public static void Log(Exception exception, string additional)
OnEvent(EventLogEntryType.Error, exception.Source, exception.StackTrace, name);
}
//Console.WriteLine(exception.Source + " threw exception: " + exception.ToString());
/*
*//*
if (g_onExceptionShowMessage == true)
{
ExceptionForm ef = new ExceptionForm(exception);
Expand All @@ -212,11 +222,11 @@ public static void Log(Exception exception, string additional)
System.Diagnostics.Debugger.Break();
}
ef.Dispose();
}*/
}*//*
}
catch (Exception)
{
}
}*/
}

}
Expand Down
11 changes: 6 additions & 5 deletions UPnP/HTTPRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ limitations under the License.
using System.Net;
using System.Threading;
using System.Collections;

using OpenSource.Utilities;

namespace OpenSource.UPnP
{
/// <summary>
Expand Down Expand Up @@ -326,7 +327,7 @@ private void NonPipelinedSniffPacketSink(HTTPRequest sender, HTTPMessage Respons

private void NonPipelinedResponseSink(HTTPRequest sender, HTTPMessage Response, object Tag)
{
// OpenSource.Utilities.EventLogger.Log(sender.s,System.Diagnostics.EventLogEntryType.Information,"TryingToDispose");
// OpenSource.Utilities.EventLogger.Log(sender.s,EventLogEntryType.Information,"TryingToDispose");
_Source = sender.Source;
this.NotPipelinedTable.Remove(sender);
sender.Dispose();
Expand Down Expand Up @@ -515,7 +516,7 @@ private void CloseSink(HTTPSession ss)

if (TagQueue.Count > 0)
{
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Information, "Switching Pipeline Modes [" + ss.GetHashCode().ToString() + "]");
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Information, "Switching Pipeline Modes [" + ss.GetHashCode().ToString() + "]");
_PIPELINE = false;
if (!ReceivedFirstResponse)
{
Expand All @@ -525,7 +526,7 @@ private void CloseSink(HTTPSession ss)

if (!ReceivedFirstResponse)
{
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Server[" + erraddr + "] closed socket without answering");
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Server[" + erraddr + "] closed socket without answering");
err = true;
}

Expand Down Expand Up @@ -563,7 +564,7 @@ private void CreateFailedSink(HTTPSession ss)
while (TagQueue.Count > 0)
{
StateData sd = (StateData)TagQueue.Dequeue();
OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.Error, "Connection Attempt to [" + sd.Dest.ToString() + "] Refused/Failed");
OpenSource.Utilities.EventLogger.Log(this, EventLogEntryType.Error, "Connection Attempt to [" + sd.Dest.ToString() + "] Refused/Failed");

object Tag = sd.Tag;
if (sd.HeaderCB != null)
Expand Down
Loading

0 comments on commit f1aa6d5

Please sign in to comment.