diff --git a/Facepunch.Steamworks/Client/Voice.cs b/Facepunch.Steamworks/Client/Voice.cs
index 2bb02a4..1c46850 100644
--- a/Facepunch.Steamworks/Client/Voice.cs
+++ b/Facepunch.Steamworks/Client/Voice.cs
@@ -102,7 +102,15 @@ namespace Facepunch.Steamworks
uint bufferRegularLastWrite = 0;
uint bufferCompressedLastWrite = 0;
- var result = client.native.user.GetVoice( OnCompressedData != null, ReadCompressedBuffer, ReadBufferSize, out bufferCompressedLastWrite,
+ var result = client.native.user.GetAvailableVoice( out bufferCompressedLastWrite, out bufferRegularLastWrite, DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
+
+ if ( result == SteamNative.VoiceResult.NotRecording || result == SteamNative.VoiceResult.NotInitialized )
+ {
+ IsRecording = false;
+ return;
+ }
+
+ result = client.native.user.GetVoice( OnCompressedData != null, ReadCompressedBuffer, ReadBufferSize, out bufferCompressedLastWrite,
OnUncompressedData != null, (IntPtr) ReadUncompressedBuffer, ReadBufferSize, out bufferRegularLastWrite,
DesiredSampleRate == 0 ? OptimalSampleRate : DesiredSampleRate );
diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs
index 95eab74..0b3011c 100644
--- a/Facepunch.Steamworks/Server.cs
+++ b/Facepunch.Steamworks/Server.cs
@@ -24,18 +24,28 @@ namespace Facepunch.Steamworks
///
/// You game's AppId
/// The IP Address to bind to. Can be 0 to mean "any".
+ /// Port to talk to steam on, can be anything as long as it's not used.".
/// The port you game listens to for connections.
/// The port Steam should use for server queries.
/// True if you want to use VAC
/// A string defining version, ie "1001"
- public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
+ public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
{
native = new Interop.NativeInterface();
+ //
+ // If we don't have a SteamPort defined, choose one at 'random'
+ //
+ if ( SteamPort == 0 )
+ {
+ SteamPort = (ushort) new Random().Next( 10000, 60000 );
+ }
+
+
//
// Get other interfaces
//
- if ( !native.InitServer( this, IpAddress, 0, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) )
+ if ( !native.InitServer( this, IpAddress, SteamPort, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) )
{
native.Dispose();
native = null;
@@ -73,6 +83,20 @@ namespace Facepunch.Steamworks
Update();
}
+ ///
+ /// Initialize a Steam Server instance
+ ///
+ /// You game's AppId
+ /// The IP Address to bind to. Can be 0 to mean "any".
+ /// The port you game listens to for connections.
+ /// The port Steam should use for server queries.
+ /// True if you want to use VAC
+ /// A string defining version, ie "1001"
+ public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bool Secure, string VersionString ) : this( appId, IpAddress, 0, GamePort, QueryPort, Secure, VersionString )
+ {
+
+ }
+
///
/// Initialize a server - query port will use the same as GamePort (MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE)
/// This means you'll need to detect and manually process and reply to server queries.