Module ppspp_channel

Library for PPSPP over UDP, aka Swift protocol.

Description

This module implements a library of functions necessary to handle the wire-protocol of PPSPP over UDP, including functions for encoding and decoding messages.

Data Types

channel()

abstract datatype: channel()

Function Index

acquire/1allow requesting channel_worker to register an unused channel Ensure that the channel can be searched for using the swarm id.
get_channel/1helper unwrapper to pull out components from a datagram map.
get_channel_id/1
get_swarm_id/1Looks up the swarm options for a given channel in the registry.
is_channel_zero/1compare given channel for the handshake channel.
pack/1
release/1allow requesting process to release an assigned channel.
unpack_channel/1
unpack_with_rest/1unpack a channel message Deconstruct PPSPP UDP datagram into multiple erlang terms, including parsing any additional data within the same segment.
where_is/1looks up pid of the owning swarm for a given channel.

Function Details

acquire/1


acquire(Swarm_id :: ppspp_options:swarm_id()) -> channel()

allow requesting channel_worker to register an unused channel Ensure that the channel can be searched for using the swarm id.

get_channel/1


get_channel(X1 :: #{}) -> pos_integer()

helper unwrapper to pull out components from a datagram map

get_channel_id/1


get_channel_id(Channel :: channel()) -> non_neg_integer()

get_swarm_id/1


get_swarm_id(Channel :: channel()) ->{ok, ppspp_options:swarm_id()} | {error, any()}

Looks up the swarm options for a given channel in the registry.

is_channel_zero/1


is_channel_zero(X1 :: channel()) -> true | false

compare given channel for the handshake channel. All other channels must be assigned to a specific swarm or the datagram unpacker will reject them. Channel zero is the channel used during initial handshaking to negotiate and agree a dedicated channel.

pack/1


pack(Message :: ppspp_channel:channel()) -> binary()

release/1


release(Channel :: channel()) -> ok

allow requesting process to release an assigned channel. This function will crash if the channel was not registered to this process, as gproc returns badarg in this case.

unpack_channel/1


unpack_channel(Binary :: binary()) -> channel()

unpack_with_rest/1


unpack_with_rest(X1 :: binary()) -> {channel(), binary()}

unpack a channel message Deconstruct PPSPP UDP datagram into multiple erlang terms, including parsing any additional data within the same segment. Any parsing failure is fatal and will propagate back to the attempted datagram unpacking.

where_is/1


where_is(Channel :: channel()) -> {ok, pid()} | {error, any()}

looks up pid of the owning swarm for a given channel. Channels are only registered to swarm_workers; and peer_worker however may receive inbound packets for a particular swarm. It is used to locate the owning swarm in a channel when unpacking messages.