Skip to content

Commit

Permalink
add method to access backing socket to TcpSocketClient
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavisau committed Jan 10, 2016
1 parent bed01db commit b9ca85e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Sockets/Sockets.Implementation.NET/TcpSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Sockets.Plugin
/// Use the <code>WriteStream</code> and <code>ReadStream</code> properties for sending and receiving data
/// respectively.
/// </summary>
public class TcpSocketClient : ITcpSocketClient
public class TcpSocketClient : ITcpSocketClient, IExposeBackingSocket
{
private TcpClient _backingTcpClient;
private readonly int _bufferSize;
Expand Down Expand Up @@ -233,5 +233,14 @@ private void Dispose(bool disposing)
}
}

/// <summary>
/// Exposes the backing socket.
/// </summary>
public TcpClient Socket => _backingTcpClient;

/// <summary>
/// Exposes the backing socket.
/// </summary>
object IExposeBackingSocket.Socket => Socket;
}
}
12 changes: 11 additions & 1 deletion Sockets/Sockets.Implementation.WinRT/TcpSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Sockets.Plugin
/// Use the <code>WriteStream</code> and <code>ReadStream</code> properties for sending and receiving data
/// respectively.
/// </summary>
public class TcpSocketClient : ITcpSocketClient
public class TcpSocketClient : ITcpSocketClient, IExposeBackingSocket
{
#if WP80
private SocketProtectionLevel _secureSocketProtectionLevel = SocketProtectionLevel.Ssl;
Expand Down Expand Up @@ -150,5 +150,15 @@ private void Dispose(bool disposing)
(_backingStreamSocket).Dispose();
}
}

/// <summary>
/// Exposes the backing socket
/// </summary>
public StreamSocket Socket => _backingStreamSocket;

/// <summary>
/// Exposes the backing socket.
/// </summary>
object IExposeBackingSocket.Socket => Socket;
}
}
5 changes: 5 additions & 0 deletions Sockets/Sockets.Plugin.Abstractions/ITcpSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public interface ITcpSocketClient : IDisposable
/// </summary>
int RemotePort { get; }
}

public interface IExposeBackingSocket
{
object Socket { get; }
}
}
10 changes: 9 additions & 1 deletion Sockets/Sockets.Plugin/TcpSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Sockets.Plugin
/// Use the <code>WriteStream</code> and <code>ReadStream</code> properties for sending and receiving data
/// respectively.
/// </summary>
public class TcpSocketClient : ITcpSocketClient
public class TcpSocketClient : ITcpSocketClient, IExposeBackingSocket
{
/// <summary>
/// Default constructor for <code>TcpSocketClient</code>.
Expand Down Expand Up @@ -102,5 +102,13 @@ public void Dispose()
{
throw new NotImplementedException(PCL.BaitWithoutSwitchMessage);
}

/// <summary>
/// Exposes the backing socket.
/// </summary>
object IExposeBackingSocket.Socket
{
get { throw new NotImplementedException(PCL.BaitWithoutSwitchMessage); }
}
}
}

0 comments on commit b9ca85e

Please sign in to comment.