-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
[Net] Low level ENet wrappers, ENet meshes for multiplayer. #50710
Conversation
6e0dd31
to
e8a2721
Compare
What are the differences and use cases for mesh vs non-mesh peers? Is this about avoiding the need for users to forward ports when they host a server? |
No, in the mesh configuration each peer is directly connected to each other, so they can communicate directly instead of having to passing through a "server" peer. They still need to open ports in some way and could do so by port forwarding, using NAT punch-trough (which I guess would be the most common case), etc. EDIT: |
509429d
to
342bdda
Compare
342bdda
to
ff197bd
Compare
<return type="int"> | ||
</return> | ||
<description> | ||
Returns a randomly generated integer that can be used as a network unique ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ID persistent across restarts or client reconnections? This should be documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ID persistent across restarts or client reconnections?
No, it's a pseudo-random number as mentioned.
<constant name="PEER_PACKET_THROTTLE" value="7" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_LIMIT" value="8" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_COUNTER" value="9" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_EPOCH" value="10" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_ACCELERATION" value="11" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_DECELERATION" value="12" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PEER_PACKET_THROTTLE_INTERVAL" value="13" enum="PeerStatistic"> | ||
</constant> | ||
<constant name="PACKET_LOSS_SCALE" value="65536"> | ||
</constant> | ||
<constant name="PACKET_THROTTLE_SCALE" value="32"> | ||
</constant> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are missing documentation.
<constant name="PEER_PACKET_LOSS_EPOCH" value="2" enum="PeerStatistic"> | ||
</constant> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant is missing documentation.
<constant name="STATE_DISCONNECTED" value="0" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_CONNECTING" value="1" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_ACKNOWLEDGING_CONNECT" value="2" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_CONNECTION_PENDING" value="3" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_CONNECTION_SUCCEEDED" value="4" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_CONNECTED" value="5" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_DISCONNECT_LATER" value="6" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_DISCONNECTING" value="7" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_ACKNOWLEDGING_DISCONNECT" value="8" enum="PeerState"> | ||
</constant> | ||
<constant name="STATE_ZOMBIE" value="9" enum="PeerState"> | ||
</constant> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are missing documentation.
@Calinou About the constants that are missing documentation, they are also missing in ENet. I really don't feel like second-guessing the ENet author here. |
Used by ENetMultiplayerPeer and WebSocketServer to generate network IDs, and exposed to the user for p2p networks (e.g. WebRTCMultiplayerPeer) and custom MultiplayerPeer implementations.
ff197bd
to
f39547b
Compare
Thanks! |
In this PR:
MultiplayerPeer
.ENetConnection
as a low level wrapper forENetHost
.ENetPacketPeer
as a low level wrapper forENetPeer
.ENetMultiplayer
now uses the low level wrappers internally (and exposes them for extra configuration).ENetMultiplayer
server packet allocations (avoid duplicating packets as much as possible).create_mesh
andadd_mesh_peer
toENetMultiplayer
to implement a full mesh network:add_mesh_peer
takes 2 parameters, the remote peer ID, and aENetConnection
, which must have exactly one peer, in the connected state (service it manually viaservice
until connection, and only then add it to the mesh).Closes #40626