3ddelano / epic-online-services-godot

Unofficial Epic Online Services wrapper for Godot Engine 4.2 (EOSG) (includes demo project)
MIT License
175 stars 12 forks source link

P2P #11

Closed RoxDevvv closed 11 months ago

RoxDevvv commented 1 year ago

when do you think we will have p2p thank you for the great work

3ddelano commented 1 year ago

Current project is on hold as I am occupied with other things. It would be nice if we have new contributors otherwise I will continue to work on in in 1-2months.

RoxDevvv commented 1 year ago

Is godot have network transport layer if so could you give me link of example, i will try to write it

Roceh commented 1 year ago

I was looking at this myself, I think you have to inherit from PacketPeer for the transport layer and MultiplayerPeer for connection creation/management.

https://github.com/godotengine/godot/blob/4df80b0e629e25653a706f6721c13a1f9d1da368/modules/enet/enet_packet_peer.h https://github.com/godotengine/godot/blob/4df80b0e629e25653a706f6721c13a1f9d1da368/modules/enet/enet_multiplayer_peer.h

Best guess would be to look at the enet stuff and try to rework that I think.

You then set the active multiplayer peer with multiplayer.set_multiplayer_peer in GDScript.

3ddelano commented 1 year ago

Oh this looks promising. What I had in mind was to not use any Godot specific network but rather directly implement the P2P interface given by EOS. Is there any pros or cons of using either method?

Roceh commented 1 year ago

Well i think you have to map the EOS P2P layer onto the godot PacketPeer and MultiplayerPeer classes, basically create eos_packet_peer.cpp/h & eos_multiplayer_peer.cpp/h. Then the higher level godot multiplayer stuff works normally as I understand it. If you look at PacketPeer it has virtual functions get_packet and put_packet which would need to be mapped to EOS P2P calls to receive and send packets over EOS.

Roceh commented 1 year ago

I was just showing the enet one as an example of how godot uses the base class internally for the default transport. Basically it would end up something being like that but using EOS instead of ENET.

3ddelano commented 1 year ago

Doing it this way will it support Godot's networking functions like rpc, rpc_id, etc

Roceh commented 1 year ago

Yes thats my understanding.

e.g. once you implemented those two classes, you would write something like this in GDScript

# Create client.
var peer = EOSMultiplayerPeer.new()
peer.create_client(EOS_REMOTE_PLAYER_ID)
multiplayer.multiplayer_peer = peer

# Create server.
var peer = EOSMultiplayerPeer.new()
peer.create_server()
multiplayer.multiplayer_peer = peer

and then all the other multiplayer stuff @rpc, etc would just "work".

Obviously you have all the EOS lobby stuff first which the clients get the host socket id from.

RoxDevvv commented 1 year ago

Doing it this way will it support Godot's networking functions like rpc, rpc_id, etc

yes that is the purpose of the transport layer

this some examples of transport layers EOS made for unity FIshNet : https://github.com/ETdoFresh/FishyEOS Mirror: https://github.com/FakeByte/EpicOnlineTransport

LowFire commented 1 year ago

I forked the repo and am currently working on implementing the p2p interface. My fork is here: https://github.com/LowFire/epic-online-services-godot

I've made some pretty good progress so far. Still trying to work some things out and am writing unit and integration tests for it.

3ddelano commented 1 year ago

Thanks for the contribution! Hoping to see great progress.

3ddelano commented 11 months ago

Closing since merged https://github.com/3ddelano/epic-online-services-godot/pull/13