Net.go 982 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package base
  2. import (
  3. "Server-Core/Server/Base/Log"
  4. "github.com/panjf2000/gnet"
  5. "time"
  6. )
  7. type Net struct {
  8. *gnet.EventServer
  9. }
  10. func (handle *Net) OnInitComplete(srv gnet.Server) (action gnet.Action) {
  11. log.Info("开始监听端口 addr:%s, multi-cores:%t,loops:%d", srv.Addr.String(), srv.Multicore, srv.NumEventLoop)
  12. return
  13. }
  14. func (handle *Net) OnShutdown(srv gnet.Server) {
  15. log.Info("OnShutdown addr:%s, multi-cores:%t,loops:%d", srv.Addr.String(), srv.Multicore, srv.NumEventLoop)
  16. }
  17. func (handle *Net) OnOpened(c gnet.Conn) (out []byte, action gnet.Action) {
  18. log.Info("OnOpened localAddr:%d, remoteAddr:%s", c.LocalAddr().String(), c.RemoteAddr().String())
  19. return
  20. }
  21. func (handle *Net) OnClosed(c gnet.Conn, err error) (action gnet.Action) {
  22. return
  23. }
  24. func (handle *Net) React(frame []byte, c gnet.Conn) (out []byte, action gnet.Action) {
  25. return
  26. }
  27. func (handle *Net) PreWrite() {
  28. }
  29. func (handle *Net) Tick() (delay time.Duration, action gnet.Action) {
  30. return
  31. }