MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / InputWorker

Method InputWorker

world.go:466–491  ·  view source on GitHub ↗

Should be goroutine/threadsafe Only reads from world channel

(shutdown chan bool, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

464// Should be goroutine/threadsafe
465// Only reads from world channel
466func (w *World) InputWorker(shutdown chan bool, wg *sync.WaitGroup) {
467 wg.Add(1)
468
469 mudlog.Info("InputWorker", "state", "Started")
470 defer func() {
471 mudlog.Warn("InputWorker", "state", "Stopped")
472 wg.Done()
473 }()
474
475loop:
476 for {
477 select {
478 case <-shutdown:
479 mudlog.Warn(`InputWorker`, `action`, `shutdown received`)
480 break loop
481 case wi := <-w.worldInput:
482
483 events.AddToQueue(events.Input{
484 UserId: wi.FromId,
485 InputText: wi.InputText,
486 ReadyTurn: util.GetTurnCount(),
487 })
488
489 }
490 }
491}
492
493func (w *World) processInput(userId int, inputText string, flags events.EventFlag) {
494

Callers 1

mainFunction · 0.80

Calls 5

InfoFunction · 0.92
WarnFunction · 0.92
AddToQueueFunction · 0.92
GetTurnCountFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected