You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nnet/protocol/plain/event_plain.go

23 lines
505 B
Go

package plain
import (
"git.noahlan.cn/noahlan/nnet"
"git.noahlan.cn/noahlan/nnet/conn"
"git.noahlan.cn/noahlan/nnet/event"
"git.noahlan.cn/noahlan/nnet/packet"
)
func withEvents() nnet.RunOption {
return func(ngin *nnet.Engine) {
ngin.EventManager().RegisterEventFront(event.EvtOnReceive, onReceiveEvent())
}
}
func onReceiveEvent() event.OnReceiveFn {
return func(nc *conn.Connection, _ packet.IPacket) {
if nc.Status() != conn.StatusWorking {
nc.SetStatus(conn.StatusWorking)
}
}
}