component.go 651 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package loopping
  2. import (
  3. actorRemote "f1-game/internal/actor_remote"
  4. cfacade "github.com/cherry-game/cherry/facade"
  5. clog "github.com/cherry-game/cherry/logger"
  6. )
  7. type component struct {
  8. cfacade.Component
  9. envs []string
  10. }
  11. func New() *component {
  12. return &component{
  13. envs: []string{
  14. "test",
  15. "su",
  16. },
  17. }
  18. }
  19. func (c *component) Name() string {
  20. return "loop_ping_component"
  21. }
  22. func (c *component) OnAfterInit() {
  23. // if slices.Contains(c.envs, cprofile.Env()) {
  24. // for range 128 {
  25. // go c.ping()
  26. // }
  27. // }
  28. }
  29. func (c *component) ping() {
  30. for {
  31. if actorRemote.CenterOps.Ping() {
  32. } else {
  33. clog.Warn("ping error")
  34. }
  35. }
  36. }