mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-04 01:30:30 +03:00
SteamNetworkingMicroseconds => long
This commit is contained in:
parent
16851f1228
commit
b171e22861
@ -98,7 +98,6 @@ namespace Steamworks
|
|||||||
|
|
||||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
|
|
||||||
while ( Connected )
|
while ( Connected )
|
||||||
{
|
{
|
||||||
Receive();
|
Receive();
|
||||||
@ -106,15 +105,13 @@ namespace Steamworks
|
|||||||
|
|
||||||
if ( sw.Elapsed.TotalSeconds > 5 )
|
if ( sw.Elapsed.TotalSeconds > 5 )
|
||||||
{
|
{
|
||||||
Console.WriteLine( "CLIENT ERROR!!!!! TIMED OUT" );
|
Assert.Fail( "Client Took Too Long" );
|
||||||
break;
|
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
|
// We're only sending strings, so it's fine to read this like this
|
||||||
var str = UTF8Encoding.UTF8.GetString( (byte*) data, size );
|
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" ) )
|
if ( str.Contains( "how about yourself" ) )
|
||||||
{
|
{
|
||||||
Connection.SendMessage( "I'm great, but I have to go now, bye." );
|
Connection.SendMessage( "I'm great, but I have to go now, bye." );
|
||||||
@ -192,13 +194,15 @@ namespace Steamworks
|
|||||||
var singleClient = Connected.First();
|
var singleClient = Connected.First();
|
||||||
|
|
||||||
singleClient.SendMessage( "Hey?" );
|
singleClient.SendMessage( "Hey?" );
|
||||||
await Task.Delay( 1000 );
|
await Task.Delay( 100 );
|
||||||
singleClient.SendMessage( "Anyone?" );
|
singleClient.SendMessage( "Anyone?" );
|
||||||
await Task.Delay( 100 );
|
await Task.Delay( 100 );
|
||||||
singleClient.SendMessage( "What's this?" );
|
singleClient.SendMessage( "What's this?" );
|
||||||
|
await Task.Delay( 100 );
|
||||||
|
singleClient.SendMessage( "What's your status?" );
|
||||||
await Task.Delay( 10 );
|
await Task.Delay( 10 );
|
||||||
singleClient.SendMessage( "Greetings!!??" );
|
singleClient.SendMessage( "Greetings!!??" );
|
||||||
await Task.Delay( 300 );
|
await Task.Delay( 100 );
|
||||||
singleClient.SendMessage( "Hello Client!?" );
|
singleClient.SendMessage( "Hello Client!?" );
|
||||||
|
|
||||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
@ -210,7 +214,7 @@ namespace Steamworks
|
|||||||
|
|
||||||
if ( sw.Elapsed.TotalSeconds > 5 )
|
if ( sw.Elapsed.TotalSeconds > 5 )
|
||||||
{
|
{
|
||||||
Assert.Fail( "Took too long" );
|
Assert.Fail( "Client Took Too Long" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +224,7 @@ namespace Steamworks
|
|||||||
Close();
|
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
|
// We're only sending strings, so it's fine to read this like this
|
||||||
var str = UTF8Encoding.UTF8.GetString( (byte*)data, size );
|
var str = UTF8Encoding.UTF8.GetString( (byte*)data, size );
|
||||||
|
@ -100,7 +100,7 @@ namespace Steamworks
|
|||||||
var msg = Marshal.PtrToStructure<NetMsg>( msgPtr );
|
var msg = Marshal.PtrToStructure<NetMsg>( msgPtr );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OnMessage( msg.DataPtr, msg.DataSize, msg.TimeRecv, msg.MessageNumber, msg.Channel );
|
OnMessage( msg.DataPtr, msg.DataSize, msg.RecvTime, msg.MessageNumber, msg.Channel );
|
||||||
}
|
}
|
||||||
finally
|
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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace Steamworks
|
|||||||
var msg = Marshal.PtrToStructure<NetMsg>( msgPtr );
|
var msg = Marshal.PtrToStructure<NetMsg>( msgPtr );
|
||||||
try
|
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
|
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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,11 +158,11 @@ namespace Steamworks
|
|||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
private delegate SteamNetworkingMicroseconds FGetLocalTimestamp( IntPtr self );
|
private delegate long FGetLocalTimestamp( IntPtr self );
|
||||||
private FGetLocalTimestamp _GetLocalTimestamp;
|
private FGetLocalTimestamp _GetLocalTimestamp;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal SteamNetworkingMicroseconds GetLocalTimestamp()
|
internal long GetLocalTimestamp()
|
||||||
{
|
{
|
||||||
return _GetLocalTimestamp( Self );
|
return _GetLocalTimestamp( Self );
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamNetworkingMicroseconds LocalTimetamp => Internal.GetLocalTimestamp();
|
public static long LocalTimetamp => Internal.GetLocalTimestamp();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -7,19 +7,17 @@ namespace Steamworks.Data
|
|||||||
[StructLayout( LayoutKind.Sequential )]
|
[StructLayout( LayoutKind.Sequential )]
|
||||||
internal struct NetMsg
|
internal struct NetMsg
|
||||||
{
|
{
|
||||||
// #32bit
|
|
||||||
internal IntPtr DataPtr;
|
internal IntPtr DataPtr;
|
||||||
internal int DataSize;
|
internal int DataSize;
|
||||||
internal NetConnection Connection;
|
internal NetConnection Connection;
|
||||||
internal NetworkIdentity Identity;
|
internal NetworkIdentity Identity;
|
||||||
internal long ConnectionUserData;
|
internal long ConnectionUserData;
|
||||||
internal SteamNetworkingMicroseconds TimeRecv;
|
internal long RecvTime;
|
||||||
internal long MessageNumber;
|
internal long MessageNumber;
|
||||||
internal IntPtr FreeDataPtr;
|
internal IntPtr FreeDataPtr;
|
||||||
internal IntPtr ReleasePtr;
|
internal IntPtr ReleasePtr;
|
||||||
internal int Channel;
|
internal int Channel;
|
||||||
|
|
||||||
|
|
||||||
internal delegate void ReleaseDelegate( IntPtr msg );
|
internal delegate void ReleaseDelegate( IntPtr msg );
|
||||||
|
|
||||||
public void Release( IntPtr data )
|
public void Release( IntPtr data )
|
||||||
|
@ -7,23 +7,6 @@ namespace Steamworks.Data
|
|||||||
{
|
{
|
||||||
delegate void FSteamNetworkingSocketsDebugOutput (SteamNetworkingSocketsDebugOutputType nType, string pszMsg );
|
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 struct SteamNetworkingPOPID
|
||||||
{
|
{
|
||||||
public uint Value;
|
public uint Value;
|
||||||
@ -56,7 +39,7 @@ namespace Steamworks.Data
|
|||||||
public int pendingUnreliable;
|
public int pendingUnreliable;
|
||||||
public int pendingReliable;
|
public int pendingReliable;
|
||||||
public int sentUnackedReliable;
|
public int sentUnackedReliable;
|
||||||
public SteamNetworkingMicroseconds queueTime;
|
public long queueTime;
|
||||||
|
|
||||||
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )]
|
[MarshalAs( UnmanagedType.ByValArray, SizeConst = 16 )]
|
||||||
uint[] reserved;
|
uint[] reserved;
|
||||||
|
@ -36,6 +36,7 @@ public static class Cleanup
|
|||||||
type = type.Replace( "SteamNetworkingIdentity", "NetworkIdentity" );
|
type = type.Replace( "SteamNetworkingIdentity", "NetworkIdentity" );
|
||||||
type = type.Replace( "SteamNetConnectionInfo_t", "ConnectionInfo" );
|
type = type.Replace( "SteamNetConnectionInfo_t", "ConnectionInfo" );
|
||||||
type = type.Replace( "SteamNetworkingConnectionState", "ConnectionState" );
|
type = type.Replace( "SteamNetworkingConnectionState", "ConnectionState" );
|
||||||
|
type = type.Replace( "SteamNetworkingMicroseconds", "long" );
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user