Peer Connection States

๐Ÿ“˜

In previous versions of the Rainway SDK onPeerConnected and onPeerDisconnected were provided instead. This functionality has moved to onPeerStateChange with the New and Failed respectively.

When using the Rainway SDK, Peers may transition across various connectivity stages based on the network topology between them. The SDK exposes these changes via the onPeerStateChange callback. This callback is invoked when a Peer first connects, when their connectivity changes, and when they fully disconnect. These states are represented by RainwayPeerState, which has the following values:

  • New - Indicates the peer is waiting for the host to allow the connection.
  • Connecting - Indicates the peer is attempting to establish a P2P connection.
  • Connected - Indicates the peer is connected.
  • Disconnected - Indicates the peer has disconnected, often for a short period during a network topology change.
  • Failed - Indicates the peer has failed to establish a P2P connection or has been fully disconnected.

It's quite common to see rapid transitions from New => Connecting => Connected during session establishment, as well as transitions from Connected => Disconnected => Connecting => Connected during network topology changes.