diff --git a/Facepunch.Steamworks/SteamNetworkingSockets.cs b/Facepunch.Steamworks/SteamNetworkingSockets.cs index 1891309..ea5e983 100644 --- a/Facepunch.Steamworks/SteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/SteamNetworkingSockets.cs @@ -167,6 +167,9 @@ public static ConnectionManager ConnectNormal( NetAddress address, IConnectionMa /// /// Creates a server that will be relayed via Valve's network (hiding the IP and improving ping) + /// + /// To use this derive a class from SocketManager and override as much as you want. + /// /// public static T CreateRelaySocket( int virtualport = 0 ) where T : SocketManager, new() { @@ -178,6 +181,31 @@ public static ConnectionManager ConnectNormal( NetAddress address, IConnectionMa return t; } + /// + /// Creates a server that will be relayed via Valve's network (hiding the IP and improving ping) + /// + /// To use this you should pass a class that inherits ISocketManager. You can use + /// SocketManager to get connections and send messages, but the ISocketManager class + /// will received all the appropriate callbacks. + /// + /// + public static SocketManager CreateRelaySocket( int virtualport, ISocketManager intrface ) + { + var options = Array.Empty(); + var socket = Internal.CreateListenSocketP2P( virtualport, options.Length, options ); + + var t = new SocketManager + { + Socket = socket, + Interface = intrface + }; + + t.Initialize(); + + SetSocketManager( t.Socket.Id, t ); + return t; + } + /// /// Connect to a relay server ///