mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Test fixes
This commit is contained in:
parent
3255135df1
commit
c1d611dae7
@ -14,7 +14,25 @@ namespace Steamworks
|
|||||||
[AssemblyInitialize]
|
[AssemblyInitialize]
|
||||||
public static void AssemblyInit( TestContext context )
|
public static void AssemblyInit( TestContext context )
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Init Client
|
||||||
|
//
|
||||||
Steamworks.Steam.Init( 4000 );
|
Steamworks.Steam.Init( 4000 );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Init Server
|
||||||
|
//
|
||||||
|
var serverInit = new ServerInit( "gmod", "Garry Mode" )
|
||||||
|
{
|
||||||
|
GamePort = 28015,
|
||||||
|
Secure = true,
|
||||||
|
QueryPort = 28016
|
||||||
|
};
|
||||||
|
|
||||||
|
Steamworks.GameServer.Init( 4000, serverInit );
|
||||||
|
|
||||||
|
GameServer.LogOnAnonymous();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnNewUrlLaunchParameters()
|
static void OnNewUrlLaunchParameters()
|
@ -88,25 +88,25 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\AchievementsTest.cs" />
|
<Compile Include="AchievementsTest.cs" />
|
||||||
<Compile Include="Client\UserTest.cs" />
|
<Compile Include="UserTest.cs" />
|
||||||
<Compile Include="Client\UtilsTest.cs" />
|
<Compile Include="UtilsTest.cs" />
|
||||||
<Compile Include="Client\ClientTest.cs" />
|
<Compile Include="ClientTest.cs" />
|
||||||
<Compile Include="Client\LobbyTest.cs" />
|
<Compile Include="LobbyTest.cs" />
|
||||||
<Compile Include="Client\LeaderboardTest.cs" />
|
<Compile Include="LeaderboardTest.cs" />
|
||||||
<Compile Include="Client\AppTest.cs" />
|
<Compile Include="AppTest.cs" />
|
||||||
<Compile Include="Client\RemoteStorageTest.cs" />
|
<Compile Include="RemoteStorageTest.cs" />
|
||||||
<Compile Include="Client\InventoryTest.cs" />
|
<Compile Include="InventoryTest.cs" />
|
||||||
<Compile Include="Client\WorkshopTest.cs" />
|
<Compile Include="WorkshopTest.cs" />
|
||||||
<Compile Include="Client\NetworkingTest.cs" />
|
<Compile Include="NetworkingTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Client\FriendsTest.cs" />
|
<Compile Include="FriendsTest.cs" />
|
||||||
<Compile Include="Client\Server\ServerTest.cs" />
|
<Compile Include="GameServerTest.cs" />
|
||||||
<Compile Include="Client\Server\StatsTest.cs" />
|
<Compile Include="Client\Server\StatsTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\ServerlistTest.cs" />
|
<Compile Include="ServerlistTest.cs" />
|
||||||
<Compile Include="Client\StatsTest.cs" />
|
<Compile Include="StatsTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -1,63 +1,46 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
/*
|
|
||||||
namespace Facepunch.Steamworks.Test
|
namespace Steamworks
|
||||||
{
|
{
|
||||||
[DeploymentItem( "steam_api64.dll" )]
|
[DeploymentItem( "steam_api64.dll" )]
|
||||||
[DeploymentItem( "tier0_s64.dll" )]
|
[DeploymentItem( "tier0_s64.dll" )]
|
||||||
[DeploymentItem( "vstdlib_s64.dll" )]
|
[DeploymentItem( "vstdlib_s64.dll" )]
|
||||||
[DeploymentItem( "steamclient64.dll" )]
|
[DeploymentItem( "steamclient64.dll" )]
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public partial class Server
|
public partial class GameServerTest
|
||||||
{
|
{
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
var serverInit = new ServerInit( "rust", "Rust" );
|
GameServer.DedicatedServer = true;
|
||||||
serverInit.GamePort = 28015;
|
GameServer.DedicatedServer = false;
|
||||||
serverInit.Secure = true;
|
}
|
||||||
serverInit.QueryPort = 28016;
|
|
||||||
|
|
||||||
using ( var server = new Facepunch.Steamworks.Server( 252490, serverInit ) )
|
|
||||||
{
|
|
||||||
server.ServerName = "My Test Server";
|
|
||||||
server.LogOnAnonymous();
|
|
||||||
|
|
||||||
Assert.IsTrue( server.IsValid );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void PublicIp()
|
public async Task PublicIp()
|
||||||
{
|
{
|
||||||
using ( var server = new Facepunch.Steamworks.Server( 252490, new ServerInit( "rust", "Rust" ) ) )
|
while ( true )
|
||||||
{
|
{
|
||||||
server.LogOnAnonymous();
|
var ip = GameServer.PublicIp;
|
||||||
|
|
||||||
Assert.IsTrue( server.IsValid );
|
if ( ip == null )
|
||||||
|
|
||||||
while ( true )
|
|
||||||
{
|
{
|
||||||
var ip = server.PublicIp;
|
await Task.Delay( 10 );
|
||||||
|
continue;
|
||||||
if ( ip == null )
|
|
||||||
{
|
|
||||||
System.Threading.Thread.Sleep( 100 );
|
|
||||||
server.Update();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.IsNotNull( ip );
|
|
||||||
Console.WriteLine( ip.ToString() );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.IsNotNull( ip );
|
||||||
|
Console.WriteLine( ip.ToString() );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void AuthCallback()
|
public void AuthCallback()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||||
{
|
{
|
||||||
Assert.IsTrue( client.IsValid );
|
Assert.IsTrue( client.IsValid );
|
||||||
@ -144,8 +127,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
Assert.IsTrue( !Authed );
|
Assert.IsTrue( !Authed );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
@ -8,7 +8,15 @@ public static class SteamApi
|
|||||||
{
|
{
|
||||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
|
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
|
||||||
[return: MarshalAs( UnmanagedType.U1 )]
|
[return: MarshalAs( UnmanagedType.U1 )]
|
||||||
public static extern bool Init();
|
public static extern bool SteamAPI_Init();
|
||||||
|
|
||||||
|
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_Shutdown", CallingConvention = CallingConvention.Cdecl )]
|
||||||
|
[return: MarshalAs( UnmanagedType.U1 )]
|
||||||
|
public static extern bool SteamAPI_Shutdown();
|
||||||
|
|
||||||
|
[DllImport( "Steam_api64", EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )]
|
||||||
|
[return: MarshalAs( UnmanagedType.U1 )]
|
||||||
|
public static extern bool SteamInternal_GameServer_Init( uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, int eServerMode, string pchVersionString);
|
||||||
|
|
||||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
|
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
|
||||||
public static extern int GetHSteamUser();
|
public static extern int GetHSteamUser();
|
||||||
@ -17,7 +25,7 @@ public static class SteamApi
|
|||||||
public static extern int SteamGameServer_GetHSteamUser();
|
public static extern int SteamGameServer_GetHSteamUser();
|
||||||
|
|
||||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
|
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
|
||||||
public static extern int RunCallbacks();
|
public static extern int SteamAPI_RunCallbacks();
|
||||||
|
|
||||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_RegisterCallback", CallingConvention = CallingConvention.Cdecl )]
|
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_RegisterCallback", CallingConvention = CallingConvention.Cdecl )]
|
||||||
public static extern int RegisterCallback( IntPtr pCallback, int callback );
|
public static extern int RegisterCallback( IntPtr pCallback, int callback );
|
||||||
|
@ -35,7 +35,7 @@ namespace Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static event Action<CSteamID, CSteamID, AuthSessionResponse> OnValidateAuthTicketResponse;
|
public static event Action<CSteamID, CSteamID, AuthSessionResponse> OnValidateAuthTicketResponse;
|
||||||
|
|
||||||
public static bool Init( AppId appid, ServerInit init )
|
public static void Init( AppId appid, ServerInit init )
|
||||||
{
|
{
|
||||||
uint ipaddress = 0; // Any Port
|
uint ipaddress = 0; // Any Port
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ namespace Steamworks
|
|||||||
//
|
//
|
||||||
// Get other interfaces
|
// Get other interfaces
|
||||||
//
|
//
|
||||||
if ( !Internal.InitGameServer( ipaddress, init.GamePort, init.QueryPort, (uint)( init.Secure ? 3 : 2 ), appid.Value, init.VersionString ) )
|
if ( !global::SteamApi.SteamInternal_GameServer_Init( ipaddress, init.SteamPort, init.GamePort, init.QueryPort, (int)( init.Secure ? 3 : 2 ), init.VersionString ) )
|
||||||
{
|
{
|
||||||
return false;
|
throw new System.Exception( "InitGameServer returned false" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -65,10 +65,25 @@ namespace Steamworks
|
|||||||
Passworded = false;
|
Passworded = false;
|
||||||
DedicatedServer = true;
|
DedicatedServer = true;
|
||||||
|
|
||||||
|
|
||||||
InstallEvents();
|
InstallEvents();
|
||||||
|
RunCallbacks();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
|
internal static async void RunCallbacks()
|
||||||
|
{
|
||||||
|
while ( true )
|
||||||
|
{
|
||||||
|
await Task.Delay( 16 );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SteamApi.SteamAPI_RunCallbacks();
|
||||||
|
}
|
||||||
|
catch ( System.Exception )
|
||||||
|
{
|
||||||
|
// TODO - error outputs
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -20,7 +20,7 @@ namespace Steamworks
|
|||||||
System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() );
|
System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() );
|
||||||
System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() );
|
System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() );
|
||||||
|
|
||||||
if ( !SteamApi.Init() )
|
if ( !SteamApi.SteamAPI_Init() )
|
||||||
{
|
{
|
||||||
throw new System.Exception( "SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId." );
|
throw new System.Exception( "SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId." );
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ namespace Steamworks
|
|||||||
await Task.Delay( 16 );
|
await Task.Delay( 16 );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SteamApi.RunCallbacks();
|
SteamApi.SteamAPI_RunCallbacks();
|
||||||
}
|
}
|
||||||
catch ( System.Exception )
|
catch ( System.Exception )
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace Steamworks
|
|||||||
|
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
SteamApi.RunCallbacks();
|
SteamApi.SteamAPI_RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UnregisterCallback( IntPtr intPtr )
|
internal static void UnregisterCallback( IntPtr intPtr )
|
||||||
|
@ -25,7 +25,7 @@ namespace Steamworks.Internal
|
|||||||
|
|
||||||
if ( server )
|
if ( server )
|
||||||
{
|
{
|
||||||
Self = SteamInternal.FindOrCreateUserInterface( hUser, InterfaceName );
|
Self = SteamInternal.FindOrCreateGameServerInterface( hUser, InterfaceName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user