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.
23 lines
505 B
Go
23 lines
505 B
Go
1 year ago
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|