.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the NetworkedMultiplayerPeer.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.

.. _class_NetworkedMultiplayerPeer:

NetworkedMultiplayerPeer
========================

**Inherits:** :ref:`PacketPeer<class_packetpeer>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`

**Inherited By:** :ref:`NetworkedMultiplayerENet<class_networkedmultiplayerenet>`

**Category:** Core

Brief Description
-----------------

A high-level network interface to simplify multiplayer interactions.

Member Functions
----------------

+------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`  | :ref:`get_connection_status<class_NetworkedMultiplayerPeer_get_connection_status>` **(** **)** const        |
+------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`  | :ref:`get_packet_peer<class_NetworkedMultiplayerPeer_get_packet_peer>` **(** **)** const                    |
+------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`  | :ref:`get_unique_id<class_NetworkedMultiplayerPeer_get_unique_id>` **(** **)** const                        |
+------------------------+-------------------------------------------------------------------------------------------------------------+
| void                   | :ref:`poll<class_NetworkedMultiplayerPeer_poll>` **(** **)**                                                |
+------------------------+-------------------------------------------------------------------------------------------------------------+
| void                   | :ref:`set_target_peer<class_NetworkedMultiplayerPeer_set_target_peer>` **(** :ref:`int<class_int>` id **)** |
+------------------------+-------------------------------------------------------------------------------------------------------------+

Signals
-------

.. _class_NetworkedMultiplayerPeer_connection_failed:

- **connection_failed** **(** **)**

Emitted when a connection attempt fails.

.. _class_NetworkedMultiplayerPeer_connection_succeeded:

- **connection_succeeded** **(** **)**

Emitted when a connection attempt succeeds.

.. _class_NetworkedMultiplayerPeer_peer_connected:

- **peer_connected** **(** :ref:`int<class_int>` id **)**

Emitted by the server when a client connects.

.. _class_NetworkedMultiplayerPeer_peer_disconnected:

- **peer_disconnected** **(** :ref:`int<class_int>` id **)**

Emitted by the server when a client disconnects.

.. _class_NetworkedMultiplayerPeer_server_disconnected:

- **server_disconnected** **(** **)**

Emitted by clients when the server disconnects.


Member Variables
----------------

  .. _class_NetworkedMultiplayerPeer_refuse_new_connections:

- :ref:`bool<class_bool>` **refuse_new_connections** - If ``true`` this ``NetworkedMultiplayerPeer`` refuses new connections. Default value: ``false``.

  .. _class_NetworkedMultiplayerPeer_transfer_mode:

- :ref:`TransferMode<enum_networkedmultiplayerpeer_transfermode>` **transfer_mode** - The manner in which to send packets to the ``target_peer``. See enum TransferMode.


Numeric Constants
-----------------

- **TARGET_PEER_BROADCAST** = **0** --- Packets are sent to the server and then redistributed to other peers.
- **TARGET_PEER_SERVER** = **1** --- Packets are sent to the server alone.

Enums
-----

  .. _enum_NetworkedMultiplayerPeer_TransferMode:

enum **TransferMode**

- **TRANSFER_MODE_UNRELIABLE** = **0** --- Packets are sent via unordered UDP packets.
- **TRANSFER_MODE_UNRELIABLE_ORDERED** = **1** --- Packets are sent via ordered UDP packets.
- **TRANSFER_MODE_RELIABLE** = **2** --- Packets are sent via TCP packets.

  .. _enum_NetworkedMultiplayerPeer_ConnectionStatus:

enum **ConnectionStatus**

- **CONNECTION_DISCONNECTED** = **0** --- The ongoing connection disconnected.
- **CONNECTION_CONNECTING** = **1** --- A connection attempt is ongoing.
- **CONNECTION_CONNECTED** = **2** --- The connection attempt succeeded.


Description
-----------

Manages the connection to network peers. Assigns unique IDs to each client connected to the server.

Member Function Description
---------------------------

.. _class_NetworkedMultiplayerPeer_get_connection_status:

- :ref:`int<class_int>` **get_connection_status** **(** **)** const

Returns the current state of the connection. See enum ConnectionStatus.

.. _class_NetworkedMultiplayerPeer_get_packet_peer:

- :ref:`int<class_int>` **get_packet_peer** **(** **)** const

Returns the ID of the ``NetworkedMultiplayerPeer`` who sent the most recent packet.

.. _class_NetworkedMultiplayerPeer_get_unique_id:

- :ref:`int<class_int>` **get_unique_id** **(** **)** const

Returns the ID of this ``NetworkedMultiplayerPeer``.

.. _class_NetworkedMultiplayerPeer_poll:

- void **poll** **(** **)**

Waits up to 1 second to receive a new network event.

.. _class_NetworkedMultiplayerPeer_set_target_peer:

- void **set_target_peer** **(** :ref:`int<class_int>` id **)**

The peer to which packets will be sent. Default value: ``0``.


