glisten/internal/handler
Types
pub type Connection(user_message) {
Connection(
client_ip: ClientIp,
socket: Socket,
transport: Transport,
sender: Subject(Message(user_message)),
)
}
Constructors
-
Connection( client_ip: ClientIp, socket: Socket, transport: Transport, sender: Subject(Message(user_message)), )
pub type Handler(user_message, data) {
Handler(
socket: Socket,
loop: Loop(user_message, data),
on_init: fn(Connection(user_message)) ->
#(data, Option(Selector(user_message))),
on_close: Option(fn(data) -> Nil),
transport: Transport,
)
}
Constructors
-
Handler( socket: Socket, loop: Loop(user_message, data), on_init: fn(Connection(user_message)) -> #(data, Option(Selector(user_message))), on_close: Option(fn(data) -> Nil), transport: Transport, )
All message types that the handler will receive, or that you can send to the handler process
pub type InternalMessage {
Close
Ready
ReceiveMessage(BitArray)
SslClosed
TcpClosed
}
Constructors
-
Close
-
Ready
-
ReceiveMessage(BitArray)
-
SslClosed
-
TcpClosed
pub type Loop(user_message, data) =
fn(LoopMessage(user_message), data, Connection(user_message)) ->
actor.Next(LoopMessage(user_message), data)
pub type LoopMessage(user_message) {
Packet(BitArray)
Custom(user_message)
}
Constructors
-
Packet(BitArray)
-
Custom(user_message)
pub type LoopState(user_message, data) {
LoopState(
client_ip: ClientIp,
socket: Socket,
sender: Subject(Message(user_message)),
transport: Transport,
data: data,
)
}
Constructors
-
LoopState( client_ip: ClientIp, socket: Socket, sender: Subject(Message(user_message)), transport: Transport, data: data, )