这个是啥问题,go run main.go
../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:31:2: use of internal package github.com/lonng/nano/internal/codec not allowed
../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:32:2: use of internal package github.com/lonng/nano/internal/message not allowed
../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:33:2: use of internal package github.com/lonng/nano/internal/packet not allowed
这个是啥问题,go run main.go ../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:31:2: use of internal package github.com/lonng/nano/internal/codec not allowed ../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:32:2: use of internal package github.com/lonng/nano/internal/message not allowed ../../pkg/mod/github.com/lonnng/nano@v0.4.0/agent.go:33:2: use of internal package github.com/lonng/nano/internal/packet not allowed
package main
import ( "fmt" "log" "net/http"
)
type ( // define component Room struct { component.Base group *nano.Group }
)
func NewRoom() *Room { return &Room{ group: nano.NewGroup("room"), } }
func (r Room) AfterInit() { nano.OnSessionClosed(func(s session.Session) { r.group.Leave(s) }) }
// Join room func (r Room) Join(s session.Session, msg []byte) error { s.Bind(s.ID()) // binding session uid s.Push("onMembers", &AllMembers{Members: r.group.Members()}) // notify others r.group.Broadcast("onNewUser", &NewUser{Content: fmt.Sprintf("New user: %d", s.ID())}) // new user join group r.group.Add(s) // add session to group return s.Response(&JoinResponse{Result: "sucess"}) }
// Send message func (r Room) Message(s session.Session, msg *UserMessage) error { return r.group.Broadcast("onMessage", msg) }
func main() { nano.Register(NewRoom()) nano.SetSerializer(json.NewSerializer()) nano.EnableDebug() log.SetFlags(log.LstdFlags | log.Llongfile)
}