Commit Graph

60 Commits

Author SHA1 Message Date
Fletcher Dunn 7ff9c7db4c P2P trivial signaling client fixes
Handle send() or recv() returning 0.
2026-04-20 22:19:04 -07:00
Fletcher Dunn f96117f95a Port P2P trivial_signaling_server to Python
Writing it in go was a fine learning experience for me, but it was
just one more dependency/complexity and not very useful.
2026-04-18 01:01:20 -07:00
Fletcher Dunn 1d55d209f3 Increase minimum required cmake version to avoid warning 2026-04-12 11:52:01 -07:00
Timothee 'TTimo' Besset e449ea6827 cmake : fix producing a trivial_signaling_server rather than trivial_signaling_server.exe PE executable on Windows 2024-09-30 09:31:08 -07:00
Costava 0fa89dc673 Fix typo in dependency name for vcpkg example 2022-08-12 10:04:26 -07:00
Fletcher Dunn b8acef56c9 Don't #define VALVE_POSIX
I changed the Steam headers that were checking this (they are not used
in the opensource code) and it is no longer needed.

P4:7380958,7380960
2022-07-15 18:51:55 -07:00
Sam V ef4ed2e8d8 Add missing override specifier 2022-06-16 07:39:12 -07:00
Fletcher Dunn 09871d2dc4 Improve platform compatibility
Replace a bunch of non-standard defines with standard ones

Don't #define POSIX in public header or test for it.  Fixes #228.
(We shoulkd probably also make this change to Steamworks headers.)

Use IsLinux(), IsPosix(), etc instead of #ifdef LINUX or #ifdef POSIX

Moved some platform socket stuff out of steamnetworkingsockets_platform.h
and into platform_sockets.h.  (none of this is actually particular to
steamnetworkingsockets.)

Some platforms don't have IPv6 support.
2022-06-14 12:04:10 -07:00
Fletcher Dunn eb09e02ee3 Fix ICE/P2P cmake stuff
ENABLE_ICE means "enable any ICE support, including the native client"
and is on by default.  (Because the native client is not much code.)

Try to build the trivial_signling_server if we are building either
examples or tests, and ENABLE_ICE is set.  The P2P test needs it.
2022-04-26 19:05:57 -07:00
Fletcher Dunn b794235422 STEAMNETWORKINGSOCKETS_NOSTEAM is now a thing.
(Not really relevant to the opensource code.)

P4:7193707,7193716,7193719,7193724
2022-04-07 17:58:23 -07:00
Fletcher Dunn 08a8ef5af4 Add an example project that pulls in gamenetworkingsockets using vcpkg 2022-01-26 15:54:00 -08:00
Fletcher Dunn 39f481ea6f Improved vcpkg support
Moved instructions for building windows manually to a separate file
and marked that method as not supported.

- Deleted the vcpkg CONTROL file, upgrade to a modern vcpkg.json manifest.
- Added tests and examples as vcpkg "features".
- Make sure we obey static/shared from the vcpkg triplet (I believe this
  addresses #175)
- Split out the detailed instructions for how to build Windows dependencies
  manually to a separate document, so we don't clutter up the main doc.

Also:
- Examples will always link with shared lib
- Tests always link with the static lib

I'm doing my best here to obey vcpkg (and cmake in general) best
practices / conventions, but this is not really something I have
expertise in, and the documentation on all this is realy not good,
so feel free to make suggestions if you see something that could be
done better.

Possible future improvements (HELP WANTED):
- Don't select the crypto with a feature, that is explicitly listed
  in the vcpkg docs as an anti-pattern.
- Add a feature for the cert tool.
- Add more CI actions to build more platforms to make sure they
  are all working.
2021-11-17 17:25:21 -08:00
Fletcher Dunn a0f7110104 Fix compiler warnings in test_p2p
P4:6653437
2021-07-06 15:35:34 -07:00
Fletcher Dunn f98cd32f62 Oops, I think this is the correct fix for OSX. 2021-04-02 17:28:29 -07:00
Lennart Haller 9dffeb46c8 Update trivial_signaling_client.cpp
OS X does not know "SOCK_NONBLOCK".
2021-04-02 16:55:09 -07:00
Fletcher Dunn ae52d2d0ce Refactor custom signaling
Removed the word "custom" from the namesofinterfacesthatwerealreadyverylong.

Added k_ESteamNetworkingConfig_Callback_CreateConnectionSignaling, which is
a mechanism for connections that require signaling to be iniated locally.
This is used by ISteamnetwrokingSockets::ConnectP2P and connections created
using the ISteamNetworkingMessages interface....which has been added.

These changes address issue #137 and bring the opensource code more in
line with Steamworks version.

Delete the define STEAMNETWORKINGSOCKETS_HAS_DEFAULT_P2P_SIGNALING.  "Default
signaling" is a thing that can exist on any platform, and can only be determined
at runtime.  Most places that were using this actually should have been
checking STEAMNETWORKINGSOCKETS_ENABLE_STEAMNETWORKINGMESSAGES anyway, and
those two defines were equivalent in practice.
STEAMNETWORKINGSOCKETS_ENABLE_STEAMNETWORKINGMESSAGES will be defined by default.
I could add a mechanism to disable it if anybody is relaly concerned about
code size.

(Also started some refactoring of the P2P listen sockets, to merge them
with hosted dedicated server listen sockets.  The goal is to enable a
way to connected to hosted dedicated servers without tickets.  That is a work
in progress, and also not relevant to the opensource code.)
2020-10-16 15:08:16 -07:00
Fletcher Dunn 22abd07690 Sockets are hard 2020-10-09 18:54:46 -07:00
Fletcher Dunn 515a34e3cc Fix winsock issues in trivial signaling client.
Use a queue.  Unfortunately, if you try to send while the socket is not
yet connected, winsock will not buffer it for you.
2020-10-09 18:31:14 -07:00
Fletcher Dunn aae577396f Use recursive_mutex 2020-10-09 18:01:13 -07:00
Andrew Simpson 34ead6c9e2 Fixes for WebRTC / vcpkg build
* Fixed installation with WebRTC is enabled
* Added vcpkg feature option for webrtc
* Try to detect abseil before using our own submodule copy (means we can use the one from vcpkg)
* Fixed standalone example build
* Shaved down abseil dependencies and use properly namespaced names
2020-10-06 16:28:48 -07:00
Steven Noonan 8348e9234a CMake: add support for LTO/LTCG/IPO/whatever-its-called-these-days
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-09-30 16:26:07 -07:00
Steven Noonan 133f0db27d examples: don't build signaling server example if go binary is absent
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-09-18 07:24:42 -07:00
Fletcher Dunn b29911db5b Don't build example P2P server unless USE_STEAMWEBRTC.
Fixes issue #139
2020-09-14 18:03:19 -07:00
Fletcher Dunn 1d11919760 Disable some warnings in tests/examples.
Refactored a bunch of common stuff into a function to do this
2020-09-03 16:29:37 -07:00
Steven Noonan 0eedd618eb CMakeLists: normalize indentation to editorconfig, NFC
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-09-03 15:31:44 -07:00
Steven Noonan 2a5bb4d0d7 trivial_signaling_server: run through gofmt
It's a good idea to follow the golang prescribed formatting.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-09-02 22:32:49 -07:00
Steven Noonan 3dba9c2dd1 examples: use find_program instead of find_library for go
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-09-02 21:43:09 -07:00
Fletcher Dunn a419be3d1f Fix win32 compile 2020-09-02 20:21:04 -07:00
Fletcher Dunn 39f14557fb Don't build golang example signaling server on Win32 2020-09-02 20:00:57 -07:00
Fletcher Dunn 9a67f2e05b Fix infinite loop bug in example client
This took me waaaaayyyyy too long to debug.
2020-09-02 09:55:22 -07:00
Fletcher Dunn e0deb8c9b8 Add spew 2020-09-01 15:24:23 -07:00
Fletcher Dunn 123a9f4e0c Fix missing return value 2020-09-01 12:24:39 -07:00
Fletcher Dunn 91b2a0352d Fix warning 2020-09-01 12:24:30 -07:00
Fletcher Dunn 381f7f3a15 Queue greeting immediately when connecting 2020-09-01 11:19:00 -07:00
Fletcher Dunn 174d27e707 Drop meson support
I don't want to learn or maintain two build systems.  cmake is the javascript
of cross-platform build systems:  Yes, it's weird and old and crusty and you
can point out all sorts of problems with it.  But it's also what the
community is consolidating on.
2020-08-31 17:16:29 -07:00
Fletcher Dunn 3d35c23835 Move all build output to bin folder.
Not scattered throughout the tree.  This makes it easier to run tests, etc.
2020-08-31 17:07:57 -07:00
Fletcher Dunn b81bdd6ac7 P2P test mostly written.
I really need to be able to compile the webrtc code with my version
of cmake to make further progress on this.
2020-08-31 14:57:40 -07:00
Fletcher Dunn cbefc8aebd Add trivial signaling client example.
WIP.  This compiles but hasn't been tested yet.  Working on a test case
that exercises it.

Also I'm still not sure I like the way the interfaces are organized.  It's
slightly more complicated than necessary, to handle what is probably a
relatively rare use case.  Maybe the only use case I care about is "Here
is the one and only signaling service to use" and I could essentially
combine ISteamNetworkingCustomSignalingRecvContext and
ISteamNetworkingCustomSignalingService.  You could replace the default
platform service, but not mix and match.
Or maybe the only thing that is needed is some comments clarifying
the relationship between ISteamNetworkingCustomSignalingRecvContext
and ISteamNetworkingCustomSignalingService.  In both cases, the primary
purpose is to create a signaling session for a specific connection.  But
one is for remotely initiated connections (a signal that respresents a
connect request coming in) and the other is for locally-initated
requests that do not go through ConnectP2PCustomSignaling.
2020-08-30 11:55:44 -07:00
Fletcher Dunn 56adfc7037 Add a comment to desribe what this is. 2020-08-29 21:33:44 -07:00
Fletcher Dunn f3b9884170 Add a trivial P2P signaling server.
It has a really dumb client protocol, no authentication, etc.  But
it should be sufficient to illustrate how a plugin for a real signaling
service (maybe XMPP or DERP) could be written.
2020-08-29 21:02:10 -07:00
Andrew Simpson 2d1ae278d5 Added ability to install GameNetworkingSockets from CMake
Also tweaked the example chat configuration so that it can be built standalone using the installed library.
2020-08-28 17:21:40 -07:00
Fletcher Dunn 4c71718263 Changed callback mechanism.
Now you can register standard function pointers, instead of deriving
from a special class.  This means that Steam and the opensource code
can now work the same, so this fixed issue #124
2020-07-03 18:02:21 -07:00
Fletcher Dunn a9e5e86b28 Added "poll group" interface.
This is used to poll many connections in a single function call.  Previously,
this was only possible if all of the connections were those accepted on the
same listen socket.  (ReceiveMessagesOnListenSocket).  But this left out at
least two important use cases with known users:

- If you create more than one listen socket (because there is more way to
  contact your service, e.g. once for P2P and another for direct IP, and
  another for relayed connections), then you could not poll all of the
  connections efficiently.
- In P2P use cases, we may initiate many connections to peers, and we want
  to poll all of them at once.

This change is relevant to: Issue #49, Issue #50, and issue #52.  (But I don't
this it really "fixes" any of them.)
2019-12-05 15:51:33 -08:00
Fletcher Dunn aa50330f1f Add method to send a messgae without copying payload.
Fixes #51
2019-09-23 14:13:08 -07:00
Fletcher Dunn 140498490e API to atomically set initial options.
Added a mechanism to set initial options when creating a listen socket or
connection.
2019-09-02 14:34:11 -07:00
Fletcher Dunn e8bba6ade1 Added interface for app to provision cert.
Also:
- STEAMNETWORKINGSOCKETS_STEAM now mens "running on steam", not "running using
  the steam client".  STEAMNETWORKINGSOCKETS_STEAMCLIENT is for that.
- Refactored stats stuff, moved it into the namespace.  At one point I thought
  I might expose some stuff in a public interface.  For now, keeping it internal.
- Removed concept of Steam "universe" from this branch of the code.
- Don't use OVERRIDE, override works.
2019-08-29 13:42:17 -07:00
Dedmen Miller 639c093138 Fix very minor typo 2019-03-20 12:56:46 +01:00
Fletcher Dunn cb911a0277 Adjusted hacks for running without Steam.
(No functional change for opensource version.)
2019-02-09 12:19:16 -08:00
Fletcher Dunn cf12240f9a Tweak init of test/example when linking with Steam.
(No functional change in this lib.)
2019-02-05 13:13:45 -08:00
Steven Noonan 04831cf688 silence some -Wswitch warnings
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2019-01-30 21:06:14 -08:00