Facepunch / Facepunch.Steamworks

Another fucking c# Steamworks implementation
MIT License
2.95k stars 354 forks source link

Unable to CreateNormalSocket without first connecting to steam #522

Open jjolley opened 3 years ago

jjolley commented 3 years ago

Steamworks.SteamNetworkingSockets.CreateNormalSocket throws an error if Steamworks.SteamClient.Init is not first called.

Object reference not set to an instance of an object at Steamworks.SteamNetworkingSockets.CreateNormalSocket[T] (Steamworks.Data.NetAddress address) [0x0000d] in D:\a\Facepunch.Steamworks\Facepunch.Steamworks\Facepunch.Steamworks\SteamNetworkingSockets.cs:105

I understand this might be intentional. But I thought the point of using the SteamNetworkSockets library was that you could use the same code for connecting to Steam servers and not using steam servers at all. This limitation means I can't use the code when the user isn't connected to Steam.

Steps to reproduce the behavior:

  1. Don't call Steamworks.SteamClient.Init
  2. Call Steamworks.SteamNetworkSockets.CreateNormalSocket
var socketManager = SteamNetworkingSockets.CreateNormalSocket<SocketManager>(NetAddress.AnyIp(12345));

I would expect this to work without needing to connect to steam. If I called SteamNetworkingSockets.CreateRelaySocket I would expect to need to be connected to Steam, but not for creating a normal socket

Thanks for the awesome library!

Scarso327 commented 3 years ago

I've had this issue recently as well. Caused me some confusion at first until I realised. I haven't tested it but does it work when you call for SteamServer.Init?

jfaz13 commented 2 years ago

Also have this issue, would really like to use steam sockets for non-steam users as well but unless you initialize the client or the server it doesn't work as far as I can tell... Any updates on this?

I've had this issue recently as well. Caused me some confusion at first until I realised. I haven't tested it but does it work when you call for SteamServer.Init?

Yes it works if you call SteamServer.init(). That being said that doesn't do much for you in the case you want to set it up for non-steam users.