Skip to content

Commit

Permalink
first pass at binding to multiple network addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Dec 4, 2016
1 parent 5dd413d commit cf5f70d
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 117 deletions.
2 changes: 1 addition & 1 deletion MediaBrowser.Common/Net/INetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface INetworkManager
/// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
bool IsInLocalNetwork(string endpoint);

IEnumerable<IpAddressInfo> GetLocalIpAddresses();
List<IpAddressInfo> GetLocalIpAddresses();

IpAddressInfo ParseIpAddress(string ipAddress);

Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Model/Net/ISocketFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ISocketFactory
/// <summary>
/// Createa a new unicast socket using the specified local port number.
/// </summary>
IUdpSocket CreateSsdpUdpSocket(int localPort);
IUdpSocket CreateSsdpUdpSocket(IpAddressInfo localIp, int localPort);

/// <summary>
/// Createa a new multicast socket using the specified multicast IP address, multicast time to live and local port.
Expand Down
16 changes: 9 additions & 7 deletions MediaBrowser.Model/Net/IUdpSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ namespace MediaBrowser.Model.Net
/// Provides a common interface across platforms for UDP sockets used by this SSDP implementation.
/// </summary>
public interface IUdpSocket : IDisposable
{
/// <summary>
/// Waits for and returns the next UDP message sent to this socket (uni or multicast).
/// </summary>
/// <returns></returns>
Task<SocketReceiveResult> ReceiveAsync();
{
IpAddressInfo LocalIPAddress { get; }

/// <summary>
/// Waits for and returns the next UDP message sent to this socket (uni or multicast).
/// </summary>
/// <returns></returns>
Task<SocketReceiveResult> ReceiveAsync();

/// <summary>
/// Sends a UDP message to a particular end point (uni or multicast).
/// </summary>
Task SendAsync(byte[] buffer, int bytes, IpEndPointInfo endPoint);
}
}
}
3 changes: 2 additions & 1 deletion MediaBrowser.Model/Net/SocketReceiveResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public sealed class SocketReceiveResult
/// The <see cref="IpEndPointInfo"/> the data was received from.
/// </summary>
public IpEndPointInfo RemoteEndPoint { get; set; }
}
public IpAddressInfo LocalIPAddress { get; set; }
}
}
3 changes: 2 additions & 1 deletion RSSDP/ISsdpCommunicationsServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public interface ISsdpCommunicationsServer : IDisposable
/// </summary>
/// <param name="messageData">A byte array containing the data to send.</param>
/// <param name="destination">A <see cref="IpEndPointInfo"/> representing the destination address for the data. Can be either a multicast or unicast destination.</param>
Task SendMessage(byte[] messageData, IpEndPointInfo destination);
/// <param name="fromLocalIpAddress">A <see cref="IpEndPointInfo"/> The local ip address to send from, or .Any if sending from all available</param>
Task SendMessage(byte[] messageData, IpEndPointInfo destination, IpAddressInfo fromLocalIpAddress);

/// <summary>
/// Sends a message to the SSDP multicast address and port.
Expand Down
5 changes: 4 additions & 1 deletion RSSDP/RSSDP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<Compile Include="ISsdpDevicePublisher.cs" />
<Compile Include="IUPnPDeviceValidator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReadOnlyEnumerable.cs" />
<Compile Include="RequestReceivedEventArgs.cs" />
<Compile Include="ResponseReceivedEventArgs.cs" />
<Compile Include="SsdpCommunicationsServer.cs" />
Expand All @@ -70,6 +69,10 @@
<Compile Include="UPnP10DeviceValidator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
Expand Down
46 changes: 0 additions & 46 deletions RSSDP/ReadOnlyEnumerable.cs

This file was deleted.

9 changes: 5 additions & 4 deletions RSSDP/RequestReceivedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ public sealed class RequestReceivedEventArgs : EventArgs

#endregion

#region Constructors
public IpAddressInfo LocalIpAddress { get; private set; }

#region Constructors

/// <summary>
/// Full constructor.
/// </summary>
/// <param name="message">The <see cref="HttpRequestMessage"/> that was received.</param>
/// <param name="receivedFrom">A <see cref="UdpEndPoint"/> representing the sender's address (sometimes used for replies).</param>
public RequestReceivedEventArgs(HttpRequestMessage message, IpEndPointInfo receivedFrom)
public RequestReceivedEventArgs(HttpRequestMessage message, IpEndPointInfo receivedFrom, IpAddressInfo localIpAddress)
{
_Message = message;
_ReceivedFrom = receivedFrom;
LocalIpAddress = localIpAddress;
}

#endregion
Expand Down
Loading

0 comments on commit cf5f70d

Please sign in to comment.