diff --git a/Facepunch.Steamworks.Test/NetworkingSockets.cs b/Facepunch.Steamworks.Test/NetworkingSockets.cs index 43569e8..5b0439c 100644 --- a/Facepunch.Steamworks.Test/NetworkingSockets.cs +++ b/Facepunch.Steamworks.Test/NetworkingSockets.cs @@ -98,7 +98,6 @@ namespace Steamworks var sw = System.Diagnostics.Stopwatch.StartNew(); - while ( Connected ) { Receive(); @@ -106,15 +105,13 @@ namespace Steamworks if ( sw.Elapsed.TotalSeconds > 5 ) { - Console.WriteLine( "CLIENT ERROR!!!!! TIMED OUT" ); + Assert.Fail( "Client Took Too Long" ); break; } } - - Console.WriteLine( Connection.DetailedStatus() ); } - public override unsafe void OnMessage( IntPtr data, int size, long messageNum, SteamNetworkingMicroseconds recvTime, int channel ) + public override unsafe void OnMessage( IntPtr data, int size, long messageNum, long recvTime, int channel ) { // We're only sending strings, so it's fine to read this like this var str = UTF8Encoding.UTF8.GetString( (byte*) data, size ); @@ -133,6 +130,11 @@ namespace Steamworks } } + if ( str.Contains( "status" )) + { + Console.WriteLine( Connection.DetailedStatus() ); + } + if ( str.Contains( "how about yourself" ) ) { Connection.SendMessage( "I'm great, but I have to go now, bye." ); @@ -192,13 +194,15 @@ namespace Steamworks var singleClient = Connected.First(); singleClient.SendMessage( "Hey?" ); - await Task.Delay( 1000 ); + await Task.Delay( 100 ); singleClient.SendMessage( "Anyone?" ); await Task.Delay( 100 ); singleClient.SendMessage( "What's this?" ); + await Task.Delay( 100 ); + singleClient.SendMessage( "What's your status?" ); await Task.Delay( 10 ); singleClient.SendMessage( "Greetings!!??" ); - await Task.Delay( 300 ); + await Task.Delay( 100 ); singleClient.SendMessage( "Hello Client!?" ); var sw = System.Diagnostics.Stopwatch.StartNew(); @@ -210,7 +214,7 @@ namespace Steamworks if ( sw.Elapsed.TotalSeconds > 5 ) { - Assert.Fail( "Took too long" ); + Assert.Fail( "Client Took Too Long" ); break; } } @@ -220,7 +224,7 @@ namespace Steamworks Close(); } - public override unsafe void OnMessage( NetConnection connection, NetworkIdentity identity, IntPtr data, int size, long messageNum, SteamNetworkingMicroseconds recvTime, int channel ) + public override unsafe void OnMessage( NetConnection connection, NetworkIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel ) { // We're only sending strings, so it's fine to read this like this var str = UTF8Encoding.UTF8.GetString( (byte*)data, size ); diff --git a/Facepunch.Steamworks/Classes/ConnectionInterface.cs b/Facepunch.Steamworks/Classes/ConnectionInterface.cs index 1110682..a9f9884 100644 --- a/Facepunch.Steamworks/Classes/ConnectionInterface.cs +++ b/Facepunch.Steamworks/Classes/ConnectionInterface.cs @@ -100,7 +100,7 @@ namespace Steamworks var msg = Marshal.PtrToStructure( msgPtr ); try { - OnMessage( msg.DataPtr, msg.DataSize, msg.TimeRecv, msg.MessageNumber, msg.Channel ); + OnMessage( msg.DataPtr, msg.DataSize, msg.RecvTime, msg.MessageNumber, msg.Channel ); } finally { @@ -111,7 +111,7 @@ namespace Steamworks } } - public virtual void OnMessage( IntPtr data, int size, long messageNum, SteamNetworkingMicroseconds recvTime, int channel ) + public virtual void OnMessage( IntPtr data, int size, long messageNum, long recvTime, int channel ) { } diff --git a/Facepunch.Steamworks/Classes/SocketInterface.cs b/Facepunch.Steamworks/Classes/SocketInterface.cs index b14474a..e6602ca 100644 --- a/Facepunch.Steamworks/Classes/SocketInterface.cs +++ b/Facepunch.Steamworks/Classes/SocketInterface.cs @@ -95,7 +95,7 @@ namespace Steamworks var msg = Marshal.PtrToStructure( msgPtr ); try { - OnMessage( msg.Connection, msg.Identity, msg.DataPtr, msg.DataSize, msg.TimeRecv, msg.MessageNumber, msg.Channel ); + OnMessage( msg.Connection, msg.Identity, msg.DataPtr, msg.DataSize, msg.RecvTime, msg.MessageNumber, msg.Channel ); } finally { @@ -106,7 +106,7 @@ namespace Steamworks } } - public virtual void OnMessage( NetConnection connection, NetworkIdentity identity, IntPtr data, int size, long messageNum, SteamNetworkingMicroseconds recvTime, int channel ) + public virtual void OnMessage( NetConnection connection, NetworkIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel ) { } diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs index 322bf72..f8c256d 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingUtils.cs @@ -158,11 +158,11 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate SteamNetworkingMicroseconds FGetLocalTimestamp( IntPtr self ); + private delegate long FGetLocalTimestamp( IntPtr self ); private FGetLocalTimestamp _GetLocalTimestamp; #endregion - internal SteamNetworkingMicroseconds GetLocalTimestamp() + internal long GetLocalTimestamp() { return _GetLocalTimestamp( Self ); } diff --git a/Facepunch.Steamworks/SteamNetworkingUtils.cs b/Facepunch.Steamworks/SteamNetworkingUtils.cs index c2f2bbe..a8147ad 100644 --- a/Facepunch.Steamworks/SteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/SteamNetworkingUtils.cs @@ -79,7 +79,7 @@ namespace Steamworks } } - public static SteamNetworkingMicroseconds LocalTimetamp => Internal.GetLocalTimestamp(); + public static long LocalTimetamp => Internal.GetLocalTimestamp(); /// diff --git a/Facepunch.Steamworks/Structs/NetMsg.cs b/Facepunch.Steamworks/Structs/NetMsg.cs index cd79b92..0456c34 100644 --- a/Facepunch.Steamworks/Structs/NetMsg.cs +++ b/Facepunch.Steamworks/Structs/NetMsg.cs @@ -7,19 +7,17 @@ namespace Steamworks.Data [StructLayout( LayoutKind.Sequential )] internal struct NetMsg { - // #32bit internal IntPtr DataPtr; internal int DataSize; internal NetConnection Connection; internal NetworkIdentity Identity; internal long ConnectionUserData; - internal SteamNetworkingMicroseconds TimeRecv; + internal long RecvTime; internal long MessageNumber; internal IntPtr FreeDataPtr; internal IntPtr ReleasePtr; internal int Channel; - internal delegate void ReleaseDelegate( IntPtr msg ); public void Release( IntPtr data ) diff --git a/Facepunch.Steamworks/Structs/SteamNetworking.cs b/Facepunch.Steamworks/Structs/SteamNetworking.cs index ce751c2..328ed27 100644 --- a/Facepunch.Steamworks/Structs/SteamNetworking.cs +++ b/Facepunch.Steamworks/Structs/SteamNetworking.cs @@ -7,23 +7,6 @@ namespace Steamworks.Data { delegate void FSteamNetworkingSocketsDebugOutput (SteamNetworkingSocketsDebugOutputType nType, string pszMsg ); - public struct SteamNetworkingMicroseconds - { - public long Value; - - public static implicit operator SteamNetworkingMicroseconds( long value ) - { - return new SteamNetworkingMicroseconds { Value = value }; - } - - public static implicit operator long( SteamNetworkingMicroseconds value ) - { - return value.Value; - } - - public override string ToString() => Value.ToString(); - } - public struct SteamNetworkingPOPID { public uint Value; @@ -56,7 +39,7 @@ namespace Steamworks.Data public int pendingUnreliable; public int pendingReliable; public int sentUnackedReliable; - public SteamNetworkingMicroseconds queueTime; + public long queueTime; [MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )] uint[] reserved; diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs index ab791fd..66bd977 100644 --- a/Generator/Cleanup.cs +++ b/Generator/Cleanup.cs @@ -36,6 +36,7 @@ public static class Cleanup type = type.Replace( "SteamNetworkingIdentity", "NetworkIdentity" ); type = type.Replace( "SteamNetConnectionInfo_t", "ConnectionInfo" ); type = type.Replace( "SteamNetworkingConnectionState", "ConnectionState" ); + type = type.Replace( "SteamNetworkingMicroseconds", "long" ); return type; }