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.
30 lines
527 B
Go
30 lines
527 B
Go
package protocol
|
|
|
|
import (
|
|
"git.noahlan.cn/noahlan/nnet/conn"
|
|
"git.noahlan.cn/noahlan/nnet/packet"
|
|
rt "git.noahlan.cn/noahlan/nnet/router"
|
|
)
|
|
|
|
type Router struct {
|
|
handler rt.Handler
|
|
}
|
|
|
|
func NewRouter(handler rt.Handler) rt.Router {
|
|
return &Router{
|
|
handler: handler,
|
|
}
|
|
}
|
|
|
|
func (r *Router) Handle(nc *conn.Connection, pkg packet.IPacket) {
|
|
r.handler.Handle(nc, pkg)
|
|
}
|
|
|
|
func (r *Router) Register(_ any, handler rt.Handler) error {
|
|
r.handler = handler
|
|
return nil
|
|
}
|
|
|
|
func (r *Router) SetNotFoundHandler(_ rt.Handler) {
|
|
}
|