mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Restore networking interfaces
This commit is contained in:
parent
798bfa991e
commit
26e634a7f0
@ -2,8 +2,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if false
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
public class ConnectionInterface
|
||||
@ -119,6 +117,4 @@ namespace Steamworks
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@ -3,8 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Steamworks.Data;
|
||||
|
||||
#if false
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
public class SocketInterface
|
||||
@ -69,6 +67,7 @@ namespace Steamworks
|
||||
int processed = 0;
|
||||
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
processed = SteamNetworkingSockets.Internal.ReceiveMessagesOnListenSocket( Socket, messageBuffer, bufferSize );
|
||||
@ -82,6 +81,7 @@ namespace Steamworks
|
||||
{
|
||||
Marshal.FreeHGlobal( messageBuffer );
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
// Overwhelmed our buffer, keep going
|
||||
@ -111,6 +111,4 @@ namespace Steamworks
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@ -6,8 +6,6 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Steamworks.Data;
|
||||
|
||||
#if false
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
public class SteamNetworkingSockets : SteamClass
|
||||
@ -105,7 +103,8 @@ namespace Steamworks
|
||||
public static T CreateNormalSocket<T>( NetAddress address ) where T : SocketInterface, new()
|
||||
{
|
||||
var t = new T();
|
||||
t.Socket = Internal.CreateListenSocketIP( ref address );
|
||||
var options = new NetKeyValue[0];
|
||||
t.Socket = Internal.CreateListenSocketIP( ref address, options.Length, options );
|
||||
SetSocketInterface( t.Socket.Id, t );
|
||||
return t;
|
||||
}
|
||||
@ -116,7 +115,8 @@ namespace Steamworks
|
||||
public static T ConnectNormal<T>( NetAddress address ) where T : ConnectionInterface, new()
|
||||
{
|
||||
var t = new T();
|
||||
t.Connection = Internal.ConnectByIPAddress( ref address );
|
||||
var options = new NetKeyValue[0];
|
||||
t.Connection = Internal.ConnectByIPAddress( ref address, options.Length, options );
|
||||
SetConnectionInterface( t.Connection.Id, t );
|
||||
return t;
|
||||
}
|
||||
@ -127,7 +127,8 @@ namespace Steamworks
|
||||
public static T CreateRelaySocket<T>( int virtualport = 0 ) where T : SocketInterface, new()
|
||||
{
|
||||
var t = new T();
|
||||
t.Socket = Internal.CreateListenSocketP2P( virtualport );
|
||||
var options = new NetKeyValue[0];
|
||||
t.Socket = Internal.CreateListenSocketP2P( virtualport, options.Length, options );
|
||||
SetSocketInterface( t.Socket.Id, t );
|
||||
return t;
|
||||
}
|
||||
@ -139,11 +140,10 @@ namespace Steamworks
|
||||
{
|
||||
var t = new T();
|
||||
NetIdentity identity = serverId;
|
||||
t.Connection = Internal.ConnectP2P( ref identity, virtualport );
|
||||
var options = new NetKeyValue[0];
|
||||
t.Connection = Internal.ConnectP2P( ref identity, virtualport, options.Length, options );
|
||||
SetConnectionInterface( t.Connection.Id, t );
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@ -5,8 +5,6 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Steamworks.Data;
|
||||
|
||||
#if false
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
/// <summary>
|
||||
@ -63,10 +61,12 @@ namespace Steamworks
|
||||
if ( Internal.CheckPingDataUpToDate( 60.0f ) )
|
||||
return;
|
||||
|
||||
while ( Internal.IsPingMeasurementInProgress() )
|
||||
{
|
||||
await Task.Delay( 10 );
|
||||
}
|
||||
await Task.Delay( 2000 );
|
||||
|
||||
//while ( Internal.IsPingMeasurementInProgress() )
|
||||
//{
|
||||
// await Task.Delay( 10 );
|
||||
//}
|
||||
}
|
||||
|
||||
public static long LocalTimestamp => Internal.GetLocalTimestamp();
|
||||
@ -113,7 +113,7 @@ namespace Steamworks
|
||||
internal unsafe static bool GetConfigInt( NetConfig type, int value )
|
||||
{
|
||||
int* ptr = &value;
|
||||
return Internal.SetConfigValue( type, NetScope.Global, 0, NetConfigType.Int32, (IntPtr)ptr );
|
||||
return Internal.SetConfigValue( type, NetConfigScope.Global, 0, NetConfigType.Int32, (IntPtr)ptr );
|
||||
}
|
||||
|
||||
internal unsafe static int GetConfigInt( NetConfig type )
|
||||
@ -121,8 +121,8 @@ namespace Steamworks
|
||||
int value = 0;
|
||||
NetConfigType dtype = NetConfigType.Int32;
|
||||
int* ptr = &value;
|
||||
ulong size = sizeof( int );
|
||||
var result = Internal.GetConfigValue( type, NetScope.Global, 0, ref dtype, (IntPtr) ptr, ref size );
|
||||
UIntPtr size = new UIntPtr( sizeof( int ) );
|
||||
var result = Internal.GetConfigValue( type, NetConfigScope.Global, 0, ref dtype, (IntPtr) ptr, ref size );
|
||||
if ( result != NetConfigResult.OK )
|
||||
return 0;
|
||||
|
||||
@ -132,7 +132,7 @@ namespace Steamworks
|
||||
internal unsafe static bool SetConfigFloat( NetConfig type, float value )
|
||||
{
|
||||
float* ptr = &value;
|
||||
return Internal.SetConfigValue( type, NetScope.Global, 0, NetConfigType.Float, (IntPtr)ptr );
|
||||
return Internal.SetConfigValue( type, NetConfigScope.Global, 0, NetConfigType.Float, (IntPtr)ptr );
|
||||
}
|
||||
|
||||
internal unsafe static float GetConfigFloat( NetConfig type )
|
||||
@ -140,8 +140,8 @@ namespace Steamworks
|
||||
float value = 0;
|
||||
NetConfigType dtype = NetConfigType.Float;
|
||||
float* ptr = &value;
|
||||
ulong size = sizeof( float );
|
||||
var result = Internal.GetConfigValue( type, NetScope.Global, 0, ref dtype, (IntPtr)ptr, ref size );
|
||||
UIntPtr size = new UIntPtr( sizeof( float ) );
|
||||
var result = Internal.GetConfigValue( type, NetConfigScope.Global, 0, ref dtype, (IntPtr)ptr, ref size );
|
||||
if ( result != NetConfigResult.OK )
|
||||
return 0;
|
||||
|
||||
@ -154,7 +154,7 @@ namespace Steamworks
|
||||
|
||||
fixed ( byte* ptr = bytes )
|
||||
{
|
||||
return Internal.SetConfigValue( type, NetScope.Global, 0, NetConfigType.String, (IntPtr)ptr );
|
||||
return Internal.SetConfigValue( type, NetConfigScope.Global, 0, NetConfigType.String, (IntPtr)ptr );
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,5 +204,3 @@ namespace Steamworks
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if false
|
||||
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
public struct Connection
|
||||
{
|
||||
public uint Id { get; }
|
||||
public uint Id { get; set; }
|
||||
|
||||
public override string ToString() => Id.ToString();
|
||||
public static implicit operator Connection( uint value ) => new Connection() { Id = value };
|
||||
public static implicit operator uint( Connection value ) => value.Id;
|
||||
|
||||
/// <summary>
|
||||
/// Accept an incoming connection that has been received on a listen socket.
|
||||
@ -56,7 +56,8 @@ namespace Steamworks.Data
|
||||
|
||||
public Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable )
|
||||
{
|
||||
return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType );
|
||||
long messageNumber = 0;
|
||||
return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType, ref messageNumber );
|
||||
}
|
||||
|
||||
public unsafe Result SendMessage( byte[] data, SendType sendType = SendType.Reliable )
|
||||
@ -117,12 +118,3 @@ namespace Steamworks.Data
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
public struct Connection
|
||||
{
|
||||
public uint Id { get; }
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,10 +1,12 @@
|
||||
#if false
|
||||
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
public struct Socket
|
||||
{
|
||||
internal uint Id;
|
||||
public override string ToString() => Id.ToString();
|
||||
public static implicit operator Socket( uint value ) => new Socket() { Id = value };
|
||||
public static implicit operator uint( Socket value ) => value.Id;
|
||||
|
||||
/// <summary>
|
||||
/// Destroy a listen socket. All the connections that were accepting on the listen
|
||||
@ -21,13 +23,4 @@ namespace Steamworks.Data
|
||||
set => SteamNetworkingSockets.SetSocketInterface( Id, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
public struct Socket
|
||||
{
|
||||
public uint Id { get; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user