Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement P2P Interface #13

Merged
merged 37 commits into from
Nov 23, 2023
Merged

Implement P2P Interface #13

merged 37 commits into from
Nov 23, 2023

Conversation

LowFire
Copy link
Contributor

@LowFire LowFire commented Nov 22, 2023

In this pull request, I've implemented the P2P interface. IEOS has new methods that interact with the P2P interface so that it's features can be accessed by the rest of the plugin. Two new classes have been introduced; EOSGMultiplayerPeer and EOSGPacketPeerMediator. Both these classes use the p2p interface to send and receive packets, send and accept connection requests to and from remote peers, and receive notifications from the P2P interface. Users can now establish direct peer-to-peer connections with other peers over the internet by creating instances of EOSGMultiplayerPeer and creating either a server, client, or mesh instance.

Here are a list of changes and features in this pull request.

IEOS:

  • Added a handle to p2p interface
  • Added methods that access the p2p interface's features, like receiving and sending packets, accepting connection requests, managing connections with other peers, and much more.
  • Added methods that allow you add and remove callbacks that receive notifications from the p2p interface.
  • Added two new signals that get emitted when the p2p interface packet queue becomes full or when a nat type query is complete.

EOSGMultiplayerPeer:

  • New class that allows you to connect to other peers over the internet using the p2p interface.
  • Can create a server, client, or mesh instance.
  • Servers can set a socket id to listen for connection requests.
  • Clients can connect to a server by sending a connection request to the server using the remote user id of the server and the socket id it's listening on.
  • Mesh instances can arbitrarily connect to each other using add_mesh_peer() and can send packets to each other once connected.
  • Servers and mesh instances auto-accept connection requests by default. This can be turned off by using set_auto_accept_connection_requests() and the user can manually manage connection requests by connecting to the incoming_connection_request signal.
  • Servers and mesh instances can manage incoming connection requests. Can accept or deny any pending connection requests from remote peers using accept_connection_request(), deny_connection_request(), accept_all_connection_requests(), or deny_all_connection_requests().
  • Receives EOS notifications. Emits a signal when a notification is received, such as when a connection has been established, interrupted, or closed. Also emits a signal when a new connection request is received. Signals are peer_connection_established, peer_connection_interrupted, peer_connection_closed, and incoming_connection_request.
  • Can manage connected peers and their remote user ids using methods such as get_all_peers(), get_peer_user_id(), has_peer(), has_user_id(), get_peer_id().
  • Can get and set if the multiplayer instance is polling packets using set_is_polling() and is_polling()

EOSGPacketPeerMediator:

  • This is a singleton instance that manages any active EOSGMultiplayerPeer instances. When a multiplayer instance becomes active when creating a server, client, or mesh, it registers itself with the mediator. When this happens, the multiplayer instance can now receive packets, connection requests, and notifications from the p2p interface.
  • Allows users to query the state of the mediator, such as how many total packets are queued, how many packets are queued for a specific socket id, how many packets are queued that were sent from a specific peer, and several more.
  • Can get or set a packet queue size limit. The mediator will stop polling packets from the p2p interface if this limit is reached.
  • Has a few singles that users can connect to. Signals are packet_queue_full, connection_request_received, and connection_request_removed.

Other Changes:

  • Updated GDExtension from 4.0 to 4.1 (So that users using the newer versions of Godot can use this plugin. Compatibility was broken between 4.0 and 4.1.)
  • Updated EOS SDK to 1.16.1. (by recommendation of Epic Games. Some vulnerabilities have been fixed since then.)

Bug Fixes:

  • Fixed compiler error in auth_interface.cpp. Changed AccountFeatureRestrictedInfo to AccountFeatureRestrictedInfo_DEPRECATED.
  • Fixed a bug where the connect interface would throw an EOS_EResult::InvalidParameters error when trying to login using DeviceId.

@3ddelano
Copy link
Owner

This looks great. Thanks for your contribution.

@3ddelano 3ddelano merged commit 83d322c into 3ddelano:main Nov 23, 2023
@3ddelano
Copy link
Owner

It would be nice to have a minimal example using this P2P interface. If you like you can work on that too.

@LowFire
Copy link
Contributor Author

LowFire commented Nov 23, 2023

It would be nice to have a minimal example using this P2P interface. If you like you can work on that too.

I did make a simple test game that puts it into action. It's a separate Godot project though. If you want, I could add that to the repo and have that be the sample. If not, and you want something that's part of the samples project instead, then I could probably work on that at some point.

@3ddelano
Copy link
Owner

Oh it would be good to link to that project if possible in the readme.

@LowFire
Copy link
Contributor Author

LowFire commented Nov 23, 2023

Sure thing. I can go ahead and make a repo for it and have a link to it in the readme.

This was referenced Dec 5, 2023
Closed
@LowFire LowFire mentioned this pull request Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants