Skip to content

2.0 alpha 2

Pre-release
Pre-release
Compare
Choose a tag to compare
@garrynewman garrynewman released this 27 May 10:02
· 458 commits to master since this release

Facepunch.Steamworks v2.0 is an almost total rewrite of the previous version of Facepunch.Steamworks.

I felt that we should be using global static classes to make things easier, and that we were being too heavy handed in some places. This version stays a bit more faithful to the regular API, while making things a bit easier.

We're using async for callbacks too - which makes things a lot less shitty.

var leaderboard = await SteamUserStats.FindLeaderboardAsync( "Testleaderboard" );

var friendScores = await leaderboard.Value.GetScoresFromFriendsAsync();

foreach ( var e in friendScores )
{
	Console.WriteLine( $"{e.GlobalRank}: {e.Score} {e.User}" );
}

Rust

I've implemented this into Rust on the staging branch. This has meant I've added and tested everything that Rust is using, and it's being actively tested and used on Windows, Linux and Mac.

SteamNetworkingSockets

Valve's new netcode stuff is implemented, but not tested. I've tried to keep it as relatively raw as possible while keeping it relatively simple to use.

This should get better over the next few months because I intend to try replacing our current Raknet implementation with it in Rust, and also adding netcode from scratch into one of our prototypes using it.

Creating a normal socket on any/all ip addresses on port 21893:

private class MySocketInterface : SocketInterface
{
	public override unsafe void OnMessage( Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel )
	{
		// Handle Incoming Message
	}
}

var mysocket = SteamNetworkingSockets.CreateNormalSocket<MySocketInterface>( Data.NetAddress.AnyIp( 21893 ) );

Or using Valve's relay system (clients connect via the server's steamid)

var mysocket = SteamNetworkingSockets.CreateRelaySocket<MySocketInterface>();

Connecting to a normal thing

private class TestConnectionInterface : ConnectionInterface
{
	public override unsafe void OnMessage( IntPtr data, int size, long messageNum, long recvTime, int channel )
	{
		// Handle messages from server
	}
}
var connection = SteamNetworkingSockets.ConnectNormal<MyConnectionInterface>( NetAddress.From( "127.0.0.1", 21893 ) )

Or via Steam relay

var connection = SteamNetworkingSockets.ConnectRelay<TestConnectionInterface>( serverSteamId );

SocketInterface and ConnectionInterface have a few different methods you can override. SocketInterface tries to maintain a good list of connecting/connected clients to easy access.

Changes since alpha 1

  • Fixed possible crashes due to hanging pointers
  • Added InventoryRecipe
  • Added Acquired and Origin properties to InventoryItem
  • Added InventoryDef.GetRecipesContainingThis()
  • Fixed SteamInventory not getting events on server
  • Fixed server not getting inventory definitions
  • Fixed NRE in OnAchievementIconFetched
  • Added InventoryResult.BelongsTo( )
  • Async calls are abandoned if steam is released during call
  • Added GetAuthSessionTicketAsync
  • UGC Queries are all on one struct again
  • Steam types implement IComparable, IEquatable
  • Filled out FriendGameInfo
  • Added SteamInventory.StartPurchaseAsync
  • Added SteamMatchmaking.GetHistoryServers
  • Added SteamMatchmaking.GetFavoriteServers
  • Added Ugc.Item.Edit()
  • Added Steamworks.ServerList.IpList for querying an array of Ips
  • OnGameLobbyJoinRequested now passes a lobby object
  • Added SteamServerStats
  • SteamServer.Update becomes RunCallbacks, has OnCallbackException
  • Added byte version of SteamUser.DecompressVoice
  • Added SteamUserStats.ResetAll
  • OnAchievementProgress returns a Achievement instead of a string
  • Fixed using wrong struct packing on windows, sometimes
  • Added InventoryDef.IsGenerator
  • Added SteamInventory.Items (because it's nice and noob friendly)
  • Added RequestEncryptedAppTicketAsync
  • Added SteamNetworkingSockets (normal and relay)
  • Fixed some SteamInventory methods not being public
  • Added UgcEditor.WithChangeLog( changes )
  • Added UgcEditor.WithPreviewFile( file )
  • Made SteamInventory.FindDefinition public
  • Added ServerInfo.QueryRulesAsync (source style query)
  • Added Ugc.Item.Directory
  • Added SteamFriends.RequestUserInformation
  • Added ReadVoiceDataBytes
  • Added SteamNetworkUtil
  • Added SteamParties (which seems useless, lmk if you're using it)
  • Added SteamMatchmaking (lobbies)