grammy

Types

pub type Builder(user_state, user_message) {
  Builder(
    on_init: fn() ->
      #(user_state, Option(Selector(user_message))),
    port: Int,
    handler: Handler(user_state, user_message),
  )
}

Constructors

  • Builder(
      on_init: fn() -> #(user_state, Option(Selector(user_message))),
      port: Int,
      handler: Handler(user_state, user_message),
    )
pub opaque type Connection
pub type Handler(user_state, user_message) =
  fn(Message(user_message), Connection, user_state) ->
    actor.Next(user_message, user_state)
pub type Message(user_message) {
  User(message: user_message)
  Packet(ip_address: IpAddress, port: Int, data: BitArray)
}

Constructors

  • User(message: user_message)
  • Packet(ip_address: IpAddress, port: Int, data: BitArray)
pub type Socket
pub opaque type UdpServer

Functions

pub fn get_supervisor(server: UdpServer) -> Subject(Message)
pub fn ip_address_to_string(ip: #(Int, Int, Int, Int)) -> String
pub fn new(
  init init: fn() -> #(a, Option(Selector(b))),
  handler handler: fn(Message(b), Connection, a) -> Next(b, a),
) -> Builder(a, b)
pub fn port(builder: Builder(a, b), port: Int) -> Builder(a, b)
pub fn send_to(
  connection: Connection,
  address: #(Int, Int, Int, Int),
  port: Int,
  data: BytesTree,
) -> Result(Nil, Nil)
pub fn start(
  builder: Builder(a, b),
) -> Result(UdpServer, StartError)
pub fn udp_send(
  socket: Socket,
  host: #(Int, Int, Int, Int),
  port: Int,
  packet: BytesTree,
) -> Result(Nil, Nil)
Search Document