libretro.drivers.netpacket.driver

Protocol definition for the network packet interface used by netplay-aware cores.

See also

libretro.api.netpacket

The matching ctypes types and callback definitions.

Classes

NetpacketDriver

Protocol for drivers that route the netplay packet callbacks of netplay-aware cores.

class NetpacketDriver[source]

Bases: Protocol

Protocol for drivers that route the netplay packet callbacks of netplay-aware cores.

See also

libretro.api.netpacket

The matching ctypes types and callback definitions.

abstract property callback

The netplay packet callbacks registered by the core, if any.

Set by the core via RETRO_ENVIRONMENT_SET_NETPACKET_INTERFACE. None if the core has not registered netplay support.

Parameters:

value – The callbacks struct registered by the core.

Raises:

UnsupportedEnvCall – If this driver does not support netplay packets.

See also

retro_netpacket_callback

The C struct registered by the core that contains these callbacks.

abstract property version

The netplay protocol version advertised by the core, if any.

Used by the netplay layer to reject incompatible peers.

Parameters:

value – The protocol version string to advertise.

Raises:

UnsupportedEnvCall – If this driver does not advertise a protocol version.

abstractmethod start(client_id)[source]

Notify the core that a netplay session has begun for client_id.

Parameters:

client_id (ClientID (int)) – The client identifier whose session is starting.

Return type:

None

abstractmethod receive(buf, client_id)[source]

Deliver a received netplay packet to the core.

Parameters:
  • buf (memoryview) – The packet payload.

  • client_id (ClientID (int)) – The client that sent the packet.

Return type:

None

abstractmethod stop(client_id)[source]

Notify the core that the netplay session for client_id has ended.

Parameters:

client_id (ClientID (int)) – The client identifier whose session is ending.

Return type:

None

abstractmethod poll()[source]

Drain pending netplay packets and forward them to the core.

Return type:

None

abstractmethod connected(client_id)[source]

Notify the core that client_id has connected to the netplay session.

Parameters:

client_id (ClientID (int)) – The newly connected client.

Return type:

bool

Returns:

True if the connection was accepted by the core.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
abstractmethod disconnected(client_id)[source]

Notify the core that client_id has disconnected from the netplay session.

Parameters:

client_id (ClientID (int)) – The client that disconnected.

Return type:

None