Skip to content

Commit

Permalink
Fixes UPnP notification for local services.
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Aug 29, 2023
1 parent fd6dfbf commit 111ed91
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 34 deletions.
24 changes: 0 additions & 24 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,3 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2006 - 2010 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
4 changes: 2 additions & 2 deletions Test.UPnP/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections;

using System.Dynamic;
using OpenSource.UPnP;
using OpenSource.Utilities;

Expand Down Expand Up @@ -84,7 +84,7 @@ private static void AddWeMoSwitch()
localDevice.UserAgentTag = "redsonic";

// Create an instance of the BasicEvent service
dynamic instance = new {};
dynamic instance = new ExpandoObject();

// Declare the "BasicEvent1" service
var service = new UPnPService(
Expand Down
16 changes: 11 additions & 5 deletions UPnP/SSDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public SSDP(int Expiration)
int MinVal = (int)((double)SSDP_EXPIRATION * 0.25 * 1000);
int MaxVal = (int)((double)SSDP_EXPIRATION * 0.45 * 1000);

NotifyTimer.SetTimer(5000, __NotifyCheck);
__NotifyCheck(NotifyTimer);
/*
NotifyTimer.Interval = RND.Next(MinVal, MaxVal);
NotifyTimer.AutoReset = true;
Expand Down Expand Up @@ -194,7 +194,8 @@ private void SetupSessions()
session.JoinMulticastGroup(Utils.UpnpMulticastV4Addr, addr);
try
{
session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
// session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
session.Client.Disconnect(true);
}
catch (SocketException ex)
{
Expand All @@ -215,7 +216,8 @@ private void SetupSessions()
usession.Client.Bind(new IPEndPoint(addr, 0));
try
{
usession.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
// session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
session.Client.Disconnect(true);
}
catch (SocketException ex)
{
Expand Down Expand Up @@ -262,7 +264,8 @@ private void SetupSessions()
session.JoinMulticastGroup((int)addr.ScopeId, Utils.UpnpMulticastV6Addr1);
try
{
session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
// session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
session.Client.Disconnect(true);
}
catch (SocketException ex)
{
Expand All @@ -283,7 +286,8 @@ private void SetupSessions()
usession.Client.Bind(new IPEndPoint(addr, 0));
try
{
usession.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
// session.Client.IOControl(SIO_UDP_CONNRESET, inValue, outValue);
session.Client.Disconnect(true);
}
catch (SocketException ex)
{
Expand Down Expand Up @@ -352,6 +356,8 @@ private void __NotifyCheck(SafeTimer_SINGLE sender)
OnRefresh();
int MinVal = (int)((double)SSDP_EXPIRATION * 0.25 * 1000);
int MaxVal = (int)((double)SSDP_EXPIRATION * 0.45 * 1000);
sender.SetTimer(5000, __NotifyCheck);
//sender.SetTimer(RND.Next(MinVal, MaxVal), __NotifyCheck);
//NotifyTimer.Interval = RND.Next(MinVal, MaxVal);
}

Expand Down
3 changes: 1 addition & 2 deletions UPnP/SafeTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

using System;
using System.Threading;
using System.Collections;
using OpenSource.Utilities;

namespace OpenSource.UPnP
Expand Down Expand Up @@ -128,7 +127,7 @@ System.Reflection.MethodBase method
}
}
}
#if FINALIZER_CHECK
#if FINALIZER_CHECK
~SafeTimer()
{
// SWC Testing
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion UPnP/nuget_pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (-not ([string]::IsNullOrEmpty($versionStr))) {

$content | Out-File $root\$project\$project.csproj

& dotnet pack $root\$project -o .
& dotnet pack -c release $root\$project -o .
}
else {
Write-Host "Version string is empty, possibly dry run or APPVEYOR_REPO_TAG_NAME environment variable is not set"
Expand Down

0 comments on commit 111ed91

Please sign in to comment.