View Source ElvenGard.Network.PacketHandler behaviour (ElvenGard.Network v0.1.1)

Provides a behavior for handling incoming packets.

This module defines the callback handle_packet/2, which must be implemented by modules using this behavior to process incoming packets.

For detailed usage information, please refer to the packet handler guide.

Link to this section Summary

Callbacks

This callback function is called after a packet is received and decoded by the Endpoint.

Link to this section Callbacks

Link to this callback

handle_packet(packet, socket)

View Source
@callback handle_packet(packet :: struct(), socket :: ElvenGard.Network.Socket.t()) ::
  {:cont, ElvenGard.Network.Socket.t()} | {:halt, ElvenGard.Network.Socket.t()}

This callback function is called after a packet is received and decoded by the Endpoint.

It is responsible for processing the packet data and returning one of the following tuples:

  • {:cont, socket}: Indicates that packet processing is complete, and the client connection should continue.
  • {:halt, socket}: Indicates that packet processing is complete, and the client connection should be terminated.

parameters

Parameters

  • packet: The packet data as a struct.
  • socket: The socket representing the client connection.