SteamNetworkingMicroseconds => long

This commit is contained in:
Garry Newman 2019-05-06 13:26:37 +01:00
parent 16851f1228
commit b171e22861
8 changed files with 23 additions and 37 deletions

View File

@ -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 );

View File

@ -100,7 +100,7 @@ namespace Steamworks
var msg = Marshal.PtrToStructure<NetMsg>( 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 )
{
}

View File

@ -95,7 +95,7 @@ namespace Steamworks
var msg = Marshal.PtrToStructure<NetMsg>( 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 )
{
}

View File

@ -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 );
}

View File

@ -79,7 +79,7 @@ namespace Steamworks
}
}
public static SteamNetworkingMicroseconds LocalTimetamp => Internal.GetLocalTimestamp();
public static long LocalTimetamp => Internal.GetLocalTimestamp();
/// <summary>

View File

@ -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 )

View File

@ -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;

View File

@ -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;
}