mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Added SteamRemotePlay
This commit is contained in:
parent
8b2599be98
commit
f495d18ece
@ -108,6 +108,7 @@
|
||||
<Compile Include="SteamNetworkingTest.cs" />
|
||||
<Compile Include="UgcTest.cs" />
|
||||
<Compile Include="UgcEditor.cs" />
|
||||
<Compile Include="RemotePlayTest.cs" />
|
||||
<Compile Include="UserTest.cs" />
|
||||
<Compile Include="UserStatsTest.cs" />
|
||||
<Compile Include="UgcQuery.cs" />
|
||||
|
@ -101,6 +101,7 @@
|
||||
<Compile Include="NetworkingSockets.cs" />
|
||||
<Compile Include="NetworkingSocketsTest.TestConnectionInterface.cs" />
|
||||
<Compile Include="NetworkingSocketsTest.TestSocketInterface.cs" />
|
||||
<Compile Include="RemotePlayTest.cs" />
|
||||
<Compile Include="SteamMatchmakingTest.cs" />
|
||||
<Compile Include="RemoteStorageTest.cs" />
|
||||
<Compile Include="InventoryTest.cs" />
|
||||
|
30
Facepunch.Steamworks.Test/RemotePlayTest.cs
Normal file
30
Facepunch.Steamworks.Test/RemotePlayTest.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
[TestClass]
|
||||
[DeploymentItem( "steam_api64.dll" )]
|
||||
[DeploymentItem( "steam_api.dll" )]
|
||||
public class RemotePlayTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void BasicUsability()
|
||||
{
|
||||
Console.WriteLine( $"Sessions: {SteamRemotePlay.SessionCount}" );
|
||||
|
||||
var session = SteamRemotePlay.GetSession( 4 );
|
||||
|
||||
Assert.IsFalse( session.IsValid );
|
||||
Assert.IsFalse( session.SteamId.IsValid );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1927,7 +1927,7 @@ public enum ParentalFeature : int
|
||||
//
|
||||
// ESteamDeviceFormFactor
|
||||
//
|
||||
internal enum SteamDeviceFormFactor : int
|
||||
public enum SteamDeviceFormFactor : int
|
||||
{
|
||||
Unknown = 0,
|
||||
Phone = 1,
|
||||
|
@ -55,6 +55,7 @@ public static void Init( uint appid, bool asyncCallbacks = true )
|
||||
AddInterface<SteamUserStats>();
|
||||
AddInterface<SteamUtils>();
|
||||
AddInterface<SteamVideo>();
|
||||
AddInterface<SteamRemotePlay>();
|
||||
|
||||
if ( asyncCallbacks )
|
||||
{
|
||||
|
58
Facepunch.Steamworks/SteamRemotePlay.cs
Normal file
58
Facepunch.Steamworks/SteamRemotePlay.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Steamworks.Data;
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
/// <summary>
|
||||
/// Functions that provide information about Steam Remote Play sessions, streaming your game content to another computer or to a Steam Link app or hardware.
|
||||
/// </summary>
|
||||
public class SteamRemotePlay : SteamClientClass<SteamRemotePlay>
|
||||
{
|
||||
internal static ISteamRemotePlay Internal => Interface as ISteamRemotePlay;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamRemotePlay( server ) );
|
||||
|
||||
InstallEvents( server );
|
||||
}
|
||||
|
||||
internal void InstallEvents( bool server )
|
||||
{
|
||||
Dispatch.Install<SteamRemotePlaySessionConnected_t>( x => OnSessionConnected?.Invoke( x.SessionID ), server );
|
||||
Dispatch.Install<SteamRemotePlaySessionDisconnected_t>( x => OnSessionDisconnected?.Invoke( x.SessionID ), server );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a session is connected
|
||||
/// </summary>
|
||||
public static event Action<RemotePlaySession> OnSessionConnected;
|
||||
|
||||
/// <summary>
|
||||
/// Called when a session becomes disconnected
|
||||
/// </summary>
|
||||
public static event Action<RemotePlaySession> OnSessionDisconnected;
|
||||
|
||||
/// <summary>
|
||||
/// Get the number of currently connected Steam Remote Play sessions
|
||||
/// </summary>
|
||||
public static int SessionCount => (int) Internal.GetSessionCount();
|
||||
|
||||
/// <summary>
|
||||
/// Get the currently connected Steam Remote Play session ID at the specified index.
|
||||
/// IsValid will return false if it's out of bounds
|
||||
/// </summary>
|
||||
public static RemotePlaySession GetSession( int index ) => (RemotePlaySession) Internal.GetSessionID( index ).Value;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Invite a friend to Remote Play Together
|
||||
/// This returns false if the invite can't be sent
|
||||
/// </summary>
|
||||
public static bool SendInvite( SteamId steamid ) => Internal.BSendRemotePlayTogetherInvite( steamid );
|
||||
}
|
||||
}
|
38
Facepunch.Steamworks/Structs/RemotePlaySession.cs
Normal file
38
Facepunch.Steamworks/Structs/RemotePlaySession.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Steamworks.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a RemotePlaySession from the SteamRemotePlay interface
|
||||
/// </summary>
|
||||
public struct RemotePlaySession
|
||||
{
|
||||
public uint Id { get; set; }
|
||||
|
||||
public override string ToString() => Id.ToString();
|
||||
public static implicit operator RemotePlaySession( uint value ) => new RemotePlaySession() { Id = value };
|
||||
public static implicit operator uint( RemotePlaySession value ) => value.Id;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this session was valid when created. This will stay true even
|
||||
/// after disconnection - so be sure to watch SteamRemotePlay.OnSessionDisconnected
|
||||
/// </summary>
|
||||
public bool IsValid => Id > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the SteamID of the connected user
|
||||
/// </summary>
|
||||
public SteamId SteamId => SteamRemotePlay.Internal.GetSessionSteamID( Id );
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the session client device
|
||||
/// </summary>
|
||||
public string ClientName => SteamRemotePlay.Internal.GetSessionClientName( Id );
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the session client device
|
||||
/// </summary>
|
||||
public SteamDeviceFormFactor FormFactor => SteamRemotePlay.Internal.GetSessionClientFormFactor( Id );
|
||||
}
|
||||
}
|
@ -129,6 +129,7 @@ internal static string Expose( string name )
|
||||
if ( name == "PingLocation" ) return "public";
|
||||
if ( name == "ConnectionState" ) return "public";
|
||||
if ( name == "SteamNetworkingAvailability" ) return "public";
|
||||
if ( name == "SteamDeviceFormFactor" ) return "public";
|
||||
|
||||
return "internal";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user