libretro.api.netpacket¶
Network packet exchange interface types for multiplayer.
See also
Module Attributes
Send a network packet to one or all connected players. |
|
Deliver a packet received from another player to the core. |
|
Notify the core that the multiplayer session has ended. |
|
Allow the core to send packets between calls to |
|
Drain any pending incoming packets without waiting for the end of the frame. |
|
Notify the host's core that a new player has connected. |
|
Notify the host's core that a player has disconnected. |
|
Notify the core that a multiplayer session has started. |
|
Client ID that targets all connected clients. |
Classes
Flags controlling network packet delivery. |
|
Corresponds to |
- class retro_netpacket_callback[source]¶
Bases:
StructureCorresponds to
retro_netpacket_callbackinlibretro.h.A set of callbacks for network packet exchange.
>>> from libretro.api import retro_netpacket_callback >>> cb = retro_netpacket_callback() >>> cb.start is None True
- start¶
Called when a multiplayer session starts.
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- receive¶
Called when a network packet is received.
- stop¶
Called when the multiplayer session ends. Optional.
- poll¶
Called each frame to poll for network events. Optional.
- connected¶
Called when a new player connects. Host only. Optional.
- disconnected¶
Called when a player disconnects. Host only. Optional.
- protocol_version¶
Protocol version string for compatibility checks. Optional.
- __deepcopy__(_)[source]¶
Return a deep copy of this object, including all strings. Intended for use with
copy.deepcopy().>>> import copy >>> from libretro.api import retro_netpacket_callback >>> copy.deepcopy(retro_netpacket_callback()).start is None True
- retro_netpacket_send_t¶
Send a network packet to one or all connected players.
Registered by the frontend and called by the core. A single packet may carry up to 64 KB of data.
- Parameters:
flags – A bitmask of
NetpacketFlagsvalues that controls reliability, sequencing, and flushing.buf – A
c_void_ptrto the packet data, orNone(combined withlenof0) to flush previously buffered packets.len – Length of the data in
buf, in bytes.client_id – Recipient player’s client ID, or
BROADCASTto send to every connected player.
Corresponds to
retro_netpacket_send_tinlibretro.h.
- retro_netpacket_start_t¶
Notify the core that a multiplayer session has started.
Registered by the core and called by the frontend once the local player has joined the session. The core should retain
send_fn(and optionallypoll_receive_fn) for use untilretro_netpacket_stop_tis called.- Parameters:
client_id – Local player’s client ID;
0if the local player is the host.send_fn – A
retro_netpacket_send_tthat the core uses to send packets.poll_receive_fn – A
retro_netpacket_poll_receive_tthat the core uses for synchronous receives.
Corresponds to
retro_netpacket_start_tinlibretro.h.
- retro_netpacket_receive_t¶
Deliver a packet received from another player to the core.
Registered by the core and called by the frontend when a packet arrives from another player.
- Parameters:
buf – A
c_void_ptrto the received packet data.len – Length of the packet in
buf, in bytes.client_id – Client ID of the player that sent the packet.
Corresponds to
retro_netpacket_receive_tinlibretro.h.
- retro_netpacket_stop_t¶
Notify the core that the multiplayer session has ended.
Registered by the core and called by the frontend. After this call returns, the function pointers passed to
retro_netpacket_start_tare no longer valid.Corresponds to
retro_netpacket_stop_tinlibretro.h.
- retro_netpacket_poll_t¶
Allow the core to send packets between calls to
retro_run().Registered by the core and called by the frontend once per frame to update the multiplayer session.
Corresponds to
retro_netpacket_poll_tinlibretro.h.
- retro_netpacket_poll_receive_t¶
Drain any pending incoming packets without waiting for the end of the frame.
Registered by the frontend and called by the core to receive packets immediately rather than waiting for the next frame.
Corresponds to
retro_netpacket_poll_receive_tinlibretro.h.
- retro_netpacket_connected_t¶
Notify the host’s core that a new player has connected.
Registered by the core and called by the frontend on the host side only. The core may reject the new player by returning
False.- Parameters:
client_id – Client ID of the newly-connected player.
- Returns:
Corresponds to
retro_netpacket_connected_tinlibretro.h.
- retro_netpacket_disconnected_t¶
Notify the host’s core that a player has disconnected.
Registered by the core and called by the frontend on the host side only.
- Parameters:
client_id – Client ID of the player that disconnected.
Corresponds to
retro_netpacket_disconnected_tinlibretro.h.
- class NetpacketFlags[source]¶
Bases:
IntFlagFlags controlling network packet delivery.
>>> from libretro.api import NetpacketFlags >>> NetpacketFlags.RELIABLE <NetpacketFlags.RELIABLE: 1>
- UNRELIABLE = 0¶
- RELIABLE = 1¶
- UNSEQUENCED = 2¶
- FLUSH_HINT = 4¶
- __new__(value)¶
- other in self¶
Returns True if self has at least the same flags set as other.
- iter(self)¶
Returns flags in definition order.
- len(self)¶
Return the number of members (no aliases)
- classmethod self[name]¶
Return the member matching name.
- __init__()¶
- BROADCAST = 65535¶
Client ID that targets all connected clients.