grammy
Types
pub type Builder(user_state, user_message) {
Builder(
on_init: fn() ->
#(user_state, Option(Selector(user_message))),
on_close: fn(user_state) -> Nil,
port: Int,
handler: Handler(user_state, user_message),
)
}
Constructors
-
Builder( on_init: fn() -> #(user_state, Option(Selector(user_message))), on_close: fn(user_state) -> Nil, 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)
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 send_to(
connection: Connection,
address: #(Int, Int, Int, Int),
port: Int,
data: BytesBuilder,
) -> Result(Nil, Nil)